Where’s all my disk space gone! – linux

Even with today massive disk drives it’s so easy to run out of disk space. This can be a real pain if you happen to run out of space on your root volume.

So, you fancy doing some spring cleaning and want to track down where all of your space has gone.

Here’s a quick run through using nothing more than the command prompt –

To show all of your filesystems with the -m showing used/free space in megabytes

$ df -m
Filesystem   1M-blocks      Used     Available   Use%    Mounted on
simfs        10000          718      9283        8%      /

So I’m using 718 MB of my disk space but where?

For the next bit we’re going to need to be root (or root equivalent)

$ sudo -s
cd /
du -ahm --max-depth 1 --exclude /proc | sort -n

That will list the size in MB of all of the folders in root (/) with the largest last.

5    ./bin
6    ./etc
6    ./root
7    ./sbin
12    ./lib
18    ./home
154    ./var
513    ./usr

So my /usr folder is using 513MB. Now I can drill down into the folders running the same command again.

cd /usr
du -ahm --max-depth 1 --exclude /proc | sort -n

and so on.

Obviously you only want to be deleting files when you’re absolutely positive what they are used for and what impact deleting them will have on your system!

There are a whole bunch of utilities for both Windows and linux to make this process easier and prettier! Here’s a couple –

Linux – http://treesize.sourceforge.net/
Windows – http://sourceforge.net/projects/windirstat/