Tag Archives: df

Ubuntu Server: How to Free up Disk Space Software & Sites 03 APR 2013

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.

Ubuntu Server: Check how much Free Disk Space you have Available Software & Sites 16 APR 2012

When you started getting error messages that there isn’t enough disk space available in order to complete a particular action, it is probably a good time to figure out just how much free space you actually have left available to you.

To do this we use the nifty Disk Free (df) utility which will show the free space on each of the mounted file systems.

In practice:

df -h

Useful. A second tool to use in conjunction with df is du (disk usage) which will give you a break down per directory of how much space is being used.

Ubuntu Terminal: How Much Disk Space do I have Left? CodeUnit 19 AUG 2011

To see how much disk space you have left on your Ubuntu linux desktop or server via the terminal is made easy thanks to the standard df command that comes bundled in most Linux distros.

The most default way to use this is:

df -hT

where the h switch returns the size in user readable units like GBs or MBs, while the T switch prints out the filesystem type.