Home > Support > HOWTO List > Where has all my disk space gone?

Do a basic check on disk space used

You can quickly check disk space used on a server using the df command. Add the -h option for prettier numbers. eg...

 $ df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/xvda1        4G   3G  1G  75% /

Running Out of Disk Space?


du --all --one-file-system / | awk '{if($1 > 102400) print int($1/1024) "MB" " " $2 }'

This will find files/directories larger than 100MB and output something like:

    101MB /var/mail/root
    101MB /var/mail
    109MB /usr/bin

A similar command will find the biggest few directories on your server to help you narrow down your search:

du -mxS / | sort -n | tail

Places to check

Common big users of space are log files that keep growing and aren't truncated/rotated (e.g. with logrotate).

Package manager archives using a lot of space? (eg /var/cache/apt/archives). Run 'apt-get clean' or on rpm based installs do 'yum clean all' .  That will clear out the rpm files that apt downloads when it installs new RPMs.

Nine times out of ten most (possibly reclaimable) space is used up under /var or /home.  /usr will typically be largeish (a GB or two) but its contents are typically required to run your server. Don't mess with /proc.

If you need more disk space and you are on a RimuHosting VPS, you can add more space from our control panel on the resource change page.

Also check Liz's blog post for some more tips.

Disk Check Script

Looking for a script to check disk usage, and alert you when you go over a certain threshold?

# set your own email here
wget -O /etc/cron.hourly/check-disk-space http://proj.ri.mu/check-disk-space
chmod +x /etc/cron.hourly/check-disk-space
# will setup a default config file
! echo "$EMAIL" | grep -qai example && sed -i "s/root@localhost/$EMAIL/" /etc/check-disk-space.conf
echo "$EMAIL" | grep -qai example && echo "You will need to set your email address in /etc/check-disk-space.conf"