Getting customers is beneficial for any business but behind the scenes, we know that it causes some issues. You start running out of disk space due to your server filling up due to the increase in customers. The only way that you can increase the potential and efficiency of your server is to free up your disk space.
Follow the steps and your server will be more efficient than ever.
1) Delete user cPanel and Fantastico backups
One of the main reasons for a large amount of the server’s disk space running out is when user’s start making backups in the server itself instead of removing them after a download. If you have the backup feature in the cpanel enabled this will definitely be the case.
You can delete all user’s cPanel backups by using the following command:
for user in `/bin/ls -A /var/cpanel/users` ; do rm -fv /home/$user/backup-*$user.tar.gz ; done
To delete all fantastico backups use the following command:
rm -rfv /home/*/fantastico_backups
2) Move your backup files to a backup server
Another main reason is storing the backup files of your hosting server on the server itself. Many people do this because they think that it will be useful in the long run but we all know that they tend to be useless when a server failure occurs. By doing this you use up a lot of disk space unnecessarily. It would be better if you could mount a backup server to your hosting server and save the backup files there.
You can use the following methods:
- Use the option to mount external media in WHM > Configure Backups which is available on the server.
- Any other method that backs up your files without storing them locally.
3) Delete cPanel File Manager temp files
File Manager always creates a temp file that may or may not get removed based on upload
You can remove all temp files by using the following command:
rm -fv /home/*/tmp/Cpanel_*
4) Move or archive logs
Most servers have large log files which use up a lot of space.
- You can find these log files in /var/log.
- You can change the frequency and length of your logs according to your requirements in /etc/logrotate.conf and enable compression (This will compress the files and reduce the space taken by these files)
- You can also periodically transfer these server files to a backup or log server
5) Clean up Yum files
Every time you update yum it leaves package cache files on the server.
You can use the following commands to clean up yum files:
yum clean all
6) Remove cPanel update archives
cPanel and Apache update archives can leave behind unwanted files.
You can use the following commands to delete these files and free up some space:
/usr/local/apache.backup*
7) Remove pure-ftp partials
If your server runs pureFTP as an FTP daemon, the FTP server creates temporary files starting with .pureftpd-upload* when your users upload files to the server. Their files get renamed to the actual filename when the upload is completed thus, leaving such files in the server if the upload is incomplete.
You can use the following commands to delete these files:
locate .pureftpd-upload | xargs rm -fv
8) Decrease the reserved disk space
When running a df on the server you must have noticed that you only have 50GB available in your 1TB drive when you have only used 900GB. What happened to the other 50GB? By default, Linux reserves 5% of the disk space from each partition for the root user, so that the root user can still log in even if the disk is full.
If you have a larger drive you don’t necessarily need to allocate 5% of your disk space, you can decrease this value up to 2500 blocks and free up more space on your server.
You can use the following command to reduce the allocated space for root user:
tune2fs -r 2500 /dev/sda1
9) Remove unneeded accounts
If you have a larger churn rate you probably have multiple user accounts that are not in use.
In order to check suspended accounts:
Check out WHM > List Suspended Accounts or ls /var/cpanel/suspended
In order to terminate accounts:
WHM > Terminate an Account
or
You can use the following command to terminate an account:
/scripts/killacct <user> <y/n>
(y/n indicating whether to save the DNS records)
10) Check for contrabands
You can run a few locate commands to find common files associated with copyright violations, like .mp3, .avi, .exe, etc, and have your customers remove them from the server if it hinders your terms and conditions of the server.
11) Consider a larger server
The last suggestion we have for you is to move to a larger server. If you have clients who require a large disk space and you can’t seem to optimize your disk space it’s better for you to move to a larger server to accommodate the client’s requirements.