Please whitelist cPanel in your adblocker so that you’re able to see our version release promotions, thanks!

The Community Forums

Interact with an entire community of cPanel & WHM users!
cPanelResources

Tutorial Troubleshooting Disk Space Usage

Find out what's taking up your disk space.

Tags:
  1. cPanelResources
    Overview: Managing Disk Usage when it's at 100%
    Managing disk usage is crucial for any system administrator and with the help of cPanel, we provide you a variety of tools to assist you in keeping an eye on the disk usage and tracking down that disk usage.

    Imagine you just found out the server has reached 100% disk usage but do not know where space is being used. What should you check first and what should I do when a service is offline due to disk usage?

    cPanel has a great guide through or documentation located here, but below are a few more suggestions on tracking down the disk usage. I hope you find this useful.

    Disk Usage Alerts
    cPanel provides you the ability to configure alerts when the system disk is approaching a warning level as well as a critical level. There are also alerts configurable for users quotas, as well as mailbox quotas. These are configurable in the WHM interface under WHM >> Home >> Server Configuration >> Tweak Settings >> System disk space usage warnings.

    Gaining access to your server
    The first thing you need to do is gain access to the server. You'll want to either login to the server via SSH or if the WHM is operational, you can use Terminal within the WHM interface. If you're not sure how to access the server via SSH, please refer to our documentation, or our YouTube video here.

    Once you're logged into the server as the root user, first, check with the command "df -h". This outputs the partitions of the disk and their usage:

    Code:
    [root@cptech centos]# df -h
    Filesystem      Size  Used Avail Use% Mounted on
    /dev/vda1        40G   16G   25G  40% /
    devtmpfs        1.9G     0  1.9G   0% /dev
    tmpfs           1.9G     0  1.9G   0% /dev/shm
    tmpfs           1.9G   33M  1.9G   2% /run
    tmpfs           1.9G     0  1.9G   0% /sys/fs/cgroup
    /dev/loop0      477M  2.5M  449M   1% /tmp
    tmpfs           379M     0  379M   0% /run/user/1000
    [root@cptech centos]#
    If you see Avail at 0, then run:

    Code:
    du -h --exclude /proc --max-depth=1 /

    This would show us the disk usage for each folder within "/"

    Code:
    du -h --exclude /proc --max-depth=1 /
    152M    /boot
    0    /dev
    18M    /run
    0    /sys
    36M    /etc
    9.0M    /root
    700M    /var
    4.7G    /usr
    4.5M    /home
    0    /media
    0    /mnt
    116M    /opt
    0    /srv
    0    /backup
    140K    /tmp
    5.7G    /

    However, if this reports more than 0, run the following. This would provide you files and folders taking up the most space. If you have 0Mb of space left, this would only print the Largest Directories.


    Code:
    FS='/';clear;date;df -h $FS; echo "Largest Directories:"; du -hcx --max-depth=2 $FS 2>/dev/null | grep [0-9]G | sort -grk 1 | head -15 ;echo "Largest Files:"; nice -n 19 find $FS -mount -type f -print0 2>/dev/null| xargs -0 du -k | sort -rnk1| head -n20 |awk '{printf "%8d MB\t%s\n",($1/1024),$NF}'

    This will report the disk usage for the folders held within / and what files are using the most space. Here's an example of the output:

    Code:
    Filesystem      Size  Used Avail Use% Mounted on
    /dev/vda1        40G   16G   25G  40% /
    Largest Directories:
    16G    total
    16G    /
    5.1G    /usr
    5.0G    /root
    2.8G    /backups
    2.4G    /usr/local
    1.5G    /root/disual
    1.5G    /home
    1.4G    /root/homedir
    1.4G    /home/disaul
    1.2G    /var
    Largest Files:
        2798 MB    /backups/cpmove-cptest.tar.gz
        1399 MB    /root/addons
         832 MB    /root/cpmove-cptest.tar.gz
         239 MB    /usr/sbin/mysqld
         160 MB    /usr/sbin/mysqld-debug
         140 MB    /var/cache/yum/x86_64/7/epel/gen/filelists.xml
         108 MB    /usr/tmpDSK
         107 MB    /var/lib/rpm/Packages
         101 MB    /usr/lib/locale/locale-archive
          71 MB    /root/homedir/public_html/cptest/20180723_cptest_52af2c5c773dc93e2145180723071858_archive.zip
          71 MB    /root/homedir/public_html/2018/wp-snapshots/20180723_cptest_52af2c5c773dc93e2145180723071858_archive.zip
          71 MB    /root/homedir/public_html/20180723_cptest_52af2c5c773dc93e2145180723071858_archive.zip
          71 MB    /root/cptest/homedir/public_html/cptest/20180723_cptest_52af2c5c773dc93e2145180723071858_archive.zip
          71 MB    /root/cptest/homedir/public_html/2018/wp-snapshots/20180723_cptest_52af2c5c773dc93e2145180723071858_archive.zip
          71 MB    /root/cptest/homedir/public_html/20180723_cptest_52af2c5c773dc93e2145180723071858_archive.zip
          71 MB    /home/cptest/public_html/cptest/20180723_cptest_52af2c5c773dc93e2145180723071858_archive.zip
          71 MB    /home/cptest/public_html/2018/wp-snapshots/20180723_cptest_52af2c5c773dc93e2145180723071858_archive.zip
          71 MB    /home/cptest/public_html/20180723_cptest_52af2c5c773dc93e2145180723071858_archive.zip
          64 MB    /var/cache/yum/x86_64/7/epel/gen/filelists.xml.sqlite
          52 MB    /boot/initramfs-0-rescue-a9ee2c81b9484851b687e7d5ad02e0fd.img
    **Please note, if you have a VirtFS folder, this is a bind mount and not actually taking up additional space.**

    If one directory is reporting more usage than expected, you can use something like this to get a better output of that particular folder:


    Code:
    du -h —max-depth=1 /usr
    du -h —max-depth=1 /var/lib
    du -h —max-depth=1 /etc

    These two commands are great places to start to track down the disk usage from the shell interface.

    Checking disk usage from within the WHM interface
    While the WHM interface does allow you to view disk usage, it only shows you the entire disk as df -h would via SSH.

    WHM » Server Status » Service Status

    If you are tracking down a specific users disk information, you'll need to use SSH or through the WHM Terminal under WHM » Server Configuration » Terminal and use the same commands from above.

    Checking disk usage from within cPanel interface
    From within the users cPanel interface » Files » Disk Usage, you'll get a tree of the disk usage for that one account:

    Monitor your account's available space with the Disk Usage feature. All presented figures are relative to the largest directory. Use the File Manager to see usage data for individual files and the MySQL feature to see data for individual databases. For more information, read our documentation.

    Once the disk usage has been reduced and no longer at 100%, services should begin to start coming back online when chkservd performs its next service check. Alternatively, you can manually restart them from WHM >> Restart Services.

    This should provide you enough information to successfully track down the disk usage.

    If you have trouble tracking down the disk usage for your server, something in this post doesn't quite make sense, or you want to provide general feedback please feel free to respond to the corresponding forums thread for this resource.

    Thanks!
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice