Skip to main content
disk space

How To Free HDD Space On Your Server

If you notice you are not able to connect to your cPanel, Webmail, or WHM and your website is slow and giving errors, your server may be maxed out on the disk space.

How to view your overall disk size and usage?

Log into your server via SSH.

If you are using the Macintosh OS X Terminal or Linux command prompt use the following:
ssh root@ipaddress
Replace ipaddress with your server’s physical IP address
If you are using MS Windows then you can use a terminal application such as Putty.
Once you have logged in use the df command to review your disk usage.

You will get a similar to the following output.

This Output shows that out of the 154 gigs of total disk space, 153 gigs are used with 1GB of space left over. This leaves the server at 99% disk space. This is enough to cause cPanel login failures, FTP file upload errors, and slow website issues. At this point you will need to remove some of the files from the server to bring the server back to normal operation.

How to find files with a certain size

There are two commands you can use to check which folder files are taking up your disk space. You can use the “find” or the “du” command. Below explains the two commands you can use.

Finding all file sizes with the “du” command

The following command will display all files and folders sorted by MegaBytes.

You will get a similar to the following output.

This output shows that all files over 1 MB are in the /public_html. You can run this command on a directory basis to find folders that are large. Also, this command can be customized to refine your search.

Finding specific file sizes using the “find” command

Below is the “find” command that looks for specific files in the “home” directory. The following script is finding files that are 500000k or larger

The previous command will output a similar result like the following.

Here you can see that there is a backup that is 738MB large. You can find your backup files that are no longer needed and remove them to free up space.

In the example above to remove the error_log file from the userna5 account you would enter:

Delete user cPanel backups

If you have the backup feature in cPanel enabled, chances are your users are storing the backups on the server instead of downloading and removing them. On larger servers, this can account for a lot of disk space usage. You may want to consider warning your users ahead of time that backups will automatically be removed from the server after a certain period of time or on certain dates. You can mass-delete all user cPanel backups on the server with this command:

Delete cPanel File Manager temp files

When users upload files in File Manager within cPanel, File Manager creates a temp file that may or may not get removed upon upload. You can remove these files using this command:

Move or archive logs

Most of the server’s logs are stored in /var/log, which can get rather large on more populated servers. You can change the length of time and frequency of the log rotation in /etc/logrotate.conf, and enable compression to save additional space (at the expense of CPU when the logs are being gzipped). If you want older logs, consider creating a cron job to periodically transfer them to a backup or log server so they aren’t taking up space on your hosting server.

Clean up Yum files

Yum updates leave package cache files on the server. You can clean up all unneeded yum files by running:

Remove pure-ftp partials

When your users upload files to the server via FTP when your server runs pureFTP as an FTP daemon, the FTP server creates temporary files starting with .pureftpd-upload* that get renamed the the actual filename when the upload completes. If the upload doesn’t complete, these files are left on the server. You can find and delete these by running:

*If you don’t run an updatedb regularly, you might want to do so before running this command

Remove unneeded accounts

It may turn out that you have some user accounts laying around on your server that you don’t need. Check out WHM > List Suspended Accounts (or ls /var/cpanel/suspended) and look for suspended accounts that you may be able to remove from the server to free up space. You can terminate accounts in WHM > Terminate an Account or using the command:

Consider a larger server

Some of your customers may have a legitimate need for large amount of disk space, and therefore you may be unable to keep the disk space usage on your server at a reasonable level.

We would first recommend using external storage solutions to move your backups off your server. This should help to free a considerable amount of disk space, whilst allowing important backups to continue being generated.

If however you have reached a point where you have outgrown your current hard disk storage then you may need to look at migrating your platform to a new server.

SkyHosting

Best Hosting Services: .rs domain registration, Web Hosting, VPS Servers, SSL Certificates. Visit us SkyHosting.

Leave a Reply

Your email address will not be published. Required fields are marked *