11 Ways to Free Up Disk Space on a cPanel Server

11 Ways to Free Up Disk Space on a cPanel Server 5.00/5 (100.00%) 14 votes

I’m sure that most of you have been to the point where one or more of your servers start to fill up as you get more customers. The server’s performing just fine, but there’s one problem…you’re out of disk space! Here are a few simple tricks to freeing up disk space on your cPanel server to help maximize your server’s potential.

1) Delete user cPanel and Fantastsico 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:

for user in `/bin/ls -A /var/cpanel/users` ; do rm -fv /home/$user/backup-*$user.tar.gz ; done

To remove Fantastico backups:

rm -rfv /home/*/fantastico_backups

2) Move your backups offsite

Similarly to above, if you’re using the cPanel Backup System and are storing your backups locally on the server, you could be using twice as much space as you need to. Consider mounting a backup server to your hosting server and storing the backups there (there is an option to mount external media in WHM > Configure Backups) or using an alternate method of backing up your server that doesn’t involve storing the backups locally. While local backups may be convenient at times, they tend to be useless when a server failure occurs.

3) 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:

rm -fv /home/*/tmp/Cpanel_*

4) 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.

5) Remove cPanel update archives

Cpanel and EasyApache updates tend to leave behind files that you probably don’t need. The following can be deleted or moved to a backup server to free up a little bit of space:

/usr/local/apache.backup*

/home/cpeasyapache (actual name may vary depending on cpanel version)

6) Clean up Yum files

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

yum clean all

7) 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:

locate .pureftpd-upload | xargs rm -fv

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

8) Decrease the reserved disk space

By default, Linux reserves 5% of the disk space from each partition for the root user, so root can still log in even if the disk is full. You may have noticed when running a df that you may be using 900GB out of a 1TB drive, but only have 50GB available…that’s because the other 50GB is reserved.

For larger drives, you really don’t need the whole 5%. I would recommend setting this value down to 2500 blocks so you can utilize more of the disk space. You can do this with tune2fs:

tune2fs -r 2500 /dev/sda1

You’ll want to probably man the tune2fs command before you use it for other options on setting the reserved space for your partitions.

9) Remove unneeded accounts

If you have a larger churn rate you probably 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 /scripts/killacct <user> <y/n> (y/n indicating whether to save the DNS records)

10) Check for contrabands

As a hosting provider you should have a Terms of Service that specifically tells your customers what they can (or rather cannot) store on your server. Most hosts have specific rules about the hosting of non-website-related backups and copyrighted material, but don’t pro actively scan their servers for it.  It wouldn’t hurt to 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. I once cleared over 300Gb of space on a server just by having customers remove contraband files from the server. On top of that, you’re also preserving the integrity of your business from a legal standpoint.

11) 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. A lot of hosting providers have alternate servers that are more “low key” but have huge disk storage volumes to accommodate customers that have larger sites. You might want to consider investing in a server that will be less populated and only the users that occupy a large amount of space.

Don't be selfish, share!Tweet about this on TwitterShare on RedditShare on TumblrBuffer this pageDigg thisShare on FacebookFlattr the authorEmail this to someoneShare on Google+Pin on PinterestPrint this pageShare on LinkedInShare on StumbleUpon

30 Comments

  1. Pingback: Drive Warning: /dev/sda3 (/usr) is 86% full - please help - cPanel Forums

  2. Pingback: 5 Easy Tips to Free Up Disk Space on Your Server | eLief Blog

    1. Vanessa Reply

      Well, if you’re attempting to administer a server and can’t even copy the commands listed in the post, maybe you shouldn’t be doing this anyways :)

  3. Ritesh Sanap Reply

    Thanks it did work nicely, and helped me a lot , my whole server was filled and it was bit too much tricky to reduce the space and we cannot delete few stuffs from cpanel if we do not have some disk space

  4. Pingback: Removing WHM Disk Space Errors | IT Admins

  5. Pingback: Removing WHM Disk Space Errors | TurboNoc.com

  6. Pingback: Fixing Quotas on a cPanel Server | TurboNoc.com

  7. Pingback: Removing WHM Disk Space Errors :: The cPanel Admin

  8. Nishant Reply

    Good guide. But don’t you think it’d be too harsh to bluntly delete all the fantastico / softaculous backups without the permission of the users? They might have something important in there.

    Also, is there any better way to archive the emails to save some space in case the user is consuming like 10GB just for mails?

    1. Vanessa Reply

      This guide is only intended for informational purposes. Whether a system administrator would choose to do this depends on the policies of their company. Many hosts have a ToS clause stating that backups generated by cPanel (including Fantastico/Softaculous) are fair game if they are left on the server too long. Additionally, users should be responsible for maintaining their own offsite website backups.

  9. GoDiva Reply

    Very nice tips. I found out my server was filled up. Looked in the Fantastico file and saw that the file size it has backed up is really huge. That was when i decided to see what others say about deleting these file. I was worried it would have a negative impact. I have saved the file to my computer already. So, i guess i’ll have to delete it and make some space.

  10. Pingback: Pablo Valenzuela » Blog Archive » Liberar espacio en Cpanel

  11. bindiya Reply

    thanks, really helpful post. I was running out of disk space and was not able to upload any media file (pictures) on my wordpress blog. By following these tips, i was able to recover about 400 MB of disk space.

    However one should check the hosting plan, if you have bought unlimited hosting plan, you can always ask for more disk space to your hosting provider.

  12. Gerry Reply

    This post is “timeless”! Found several of these tips to be helpful today..several years later. It pops up near the top of Google results which is a good thing!

    Thanks

Leave a Reply

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

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Log in