4

I have used Ubuntu 14.04 as a server to host my company website and mailsystem. The system was online for 3 weeks before I was not able to send or receive emails. A few minutes of debugging showed the reason: No more disk space.

Filesystem      Size  Used Avail Use% Mounted on
udev            3.9G     0  3.9G   0% /dev
tmpfs           799M  8.7M  790M   2% /run
/dev/xvda1      7.8G  7.4G     0 100% /
tmpfs           3.9G     0  3.9G   0% /dev/shm
tmpfs           5.0M     0  5.0M   0% /run/lock
tmpfs           3.9G     0  3.9G   0% /sys/fs/cgroup
tmpfs           100K     0  100K   0% /run/lxcfs/controllers
tmpfs           799M     0  799M   0% /run/user/1000

Question: How can I locate the directory that occupies all the disk space?

I have tried using df -hs /path/to/directory on all root directories without luck. There is 4GB of space that is not accounted for.

muru
  • 197,895
  • 55
  • 485
  • 740
Vingtoft
  • 143
  • 1
    It really doesn't make any difference what is taking up the space... you didn't give enough space to your root / partition to begin with... only 8G. You need to enlarge this partition. Cheers, Al – heynnema Oct 25 '16 at 15:12

2 Answers2

10

Top 10 largest directories:

du -a / | sort -n -r | head -n 10

In more human readable format:

du -hsx / | sort -rh | head -10

Largest 10 files:

find / -printf '%s %p\n'| sort -nr | head -10

There is 4GB of space that is not accounted for.

Lots of small files also add up to 4Gb...


I would suggest to look at the most obvious culprit:

/var/log/

If your system has errors it will log them there. And errors for 3 weeks can quickly add up to 4Gb. Besides that: using a databases on that system? If so... check the directory where the database stores it files;/var/lib/mysql for instance.

Rinzwind
  • 299,756
2

If you prefer to use a GUI-based tool, you can use the Disk Usage Analyzer. You can use this to dig through your hard drive and look for the largest folders.

In the example below, folder usr is the largest folder with 18.9GB, opt the second largest with 2.3GB, and so on. You can click on any of the sections on the diagram on the right or click on the tree structure on the left to expand.Sample Disk Usage Analyzer

Note: finding the largest files would be hard using this tool though as it only gives the combined size of folders. That is, a folder with 200 1MB files will seem larger than a folder with a single 100MB files. Therefore, if it is the largest files and not the largest folders that you are looking for, you are better off using the command line instructions given by @Rinzwind.

Juan Antonio
  • 1,572