Where Did My Disk Space Go?

Imagine the scenario: Your application does not work, and no errors are appearing in your log files. In fact: nothing new is appearing in your log files! Bah!

And then you discover that your root file system is full. And that's the only file system on the box:

Filesystem     1K-blocks     Used Available Use% Mounted on
/dev/sda1       18451132 18451132         0 100% /

At the very least, that explains the absense of new log entries and probably also why your application is acting up.

Note that the numbers may not add up exactly. Let's ignore that for now.

So.. where did the disk space go?

The quick and simple way of finding out is to use the du command and process the output so you get the biggest hierachies at the top:

du -x -m / | sort -nr | head -25

Note: the sort command may fail due to lack of disk space - but there are ways around that.

One thing to look out for: The total disk usage of / should be close to the size of the file system. If not, then there are 3 possible reasons:

So what to do about it? Several things:

  • You probably need to clean up disk space right away

  • Consider adding disk space

  • How did the situation get this bad? You need monitoring, so you can be alerted before things get this bad! Seriously!

  • Find out what caused the growth in disk usage: Was is necessary? Is there bug that needs to be resolved?