ubuntu-10-logoEvery now and then your server will throw up its hands and declare that it has run out of space, which means that you need to go in and figure out what is taking up all the space and then a) increase the amount of available disk space or b) delete or archive things in order to free up some disk space.

As it turns out, this is mostly a manual process of locating things and deleting or clearing out if possible, and more often than not, you’ll find that overzealous logging, which even logrotate couldn’t effectively deal with, sitting at the root of your problem.

Now we’re interested in b) for this particular post, so we start by doing a Disk Free check to get a better idea of our current situation:

sudo df -h

With that information in hand we then systematically look at the problem areas with targeted calls to Disk Usage:

sudo du -h –-max-depth=1 /
sudo du -h –-max-depth=1 /var/
sudo du -h –-max-depth=1 /var/log/

Once you’ve identified a particularly large folder, check it’s contents with the usual human readable listing:

sudo ls -lha

Spot the overly large offenders and happily delete with the usual rm command. Note that for log files it might be necessary to first identify the controlling service and stop that, in order to allow you to remove the file. Also, a nifty trick if you don’t want to delete what could be important program files is to simply overwrite them with blank, thus leaving their group and file permissions perfectly intact.