How do I check the disk usage on my VPS?


How do I check my disk usage?

This article will help you determine exactly how much disk space you have remaining on your VPS service with us, as well as helping you determine exactly what is using the disk space.

Once you have logged into your server, you can see the total disk space usage with the following command:

# df -h

This will give results similar to the following:

Filesystem Size Used Avail Use% Mounted on
/dev/xvda1 50G 11G 37G 22% /
tmpfs 497M 0 497M 0% /dev/shm
/usr/tmpDSK 2.0G 35M 1.8G 2% /tmp
From those results we can see the root partition is taking up 11GB of storage, to determine the exact files which are using the storage, run the following command:

# du -hs /*

Note: This command may give errors similar to the following, feel free to ignore this:
du: cannot access `/proc/29928/task/29928/fd/4': No such file or directory

This will give results similar to the following:

4.0K /backup
6.3M /bin
73M /boot
4.0K /cgroup
124K /dev
27M /etc
430M /home
419M /lib
24M /lib64
16K /lost+found
4.0K /media
4.0K /mnt
30M /opt
0 /proc
12K /quota.user
4.0K /razor-agent.log
161M /root
9.4M /sbin
0 /scripts
4.0K /selinux
4.0K /srv
0 /sys
24K /tmp
8.1G /usr
504M /var
As an alternative, you can "pipe" these results to grep, to find only the large directories, like so:

# du -hs /* | grep G

This will only show results that are over 1GB large (or smaller files with a "G" in them).

The results in the table above show that the /usr directory is using the most space, this can be investigated further by adding the appropriate directories into your du command, like so:

# du -hs /usr/*

You can continue doing this until you get to the source of the disk space usage.

This is a really handy way to find particularly large files on your system quickly.

Did you find this article useful?  

Related Articles

© Crucial