Not enough free disk space when upgrading

Note: this answer is meant to be more of an 'explanation' than providing the best/easiest way to remove old kernels. For the best/easiest way to remove old kernels, please review the other answers.

Okay, so from the output of /etc/fstab you posted, it seems that your /boot is mounted on a separate partition, and from the output of df -h, that partition is full. This is because there are old kernels installed that are not needed; you can tell that by looking at the output of dpkg -l | grep linux-image that you posted, where you can see more than one "linux-image" with different versions. We need to remove the old versions.

First, I want you to run the command uname -r in a terminal, this will show you the kernel version you are currently using. We never want to remove that kernel version. The command will say something like this 3.5.0-26-generic. Take a note of that number, 26! The following commands will assume that that's the kernel you're running.

The command to remove an old kernel version is:

sudo apt-get purge linux-image-x.x.x-xx-generic

...where the x characters are numbers. So, in your case, because you have a lot of old versions (17, 18, 19, etc...), we would have to run this command for each of the versions, like this:

  • sudo apt-get purge linux-image-3.5.0-17-generic
  • sudo apt-get purge linux-image-3.5.0-18-generic
  • sudo apt-get purge linux-image-3.5.0-19-generic

...and so on. But, there's a way to do all of this through one command. The command is this (DO NOT RUN THE COMMAND YET! Read the following. ):

sudo apt-get purge linux-image-3.5.0-{17,18,19,21,22,23,24}-generic

This command will remove the versions mentioned in the brackets. I didn't include versions 25, 26 and 28 because of the following reasons:

  • Didn't include 26 obviously because that is the kernel version you are currently running! That's the version we got from the command uname -r, remember? We never want to remove that!
  • Didn't include 28 because that's the one that your upgrade was trying to upgrade to (you can tell that from the iF status next it, meaning that it's "half configured").
  • Didn't include 25 because it is usually good practice to leave at least one old version. So since you're running 26, we'll keep 25, so we won't include it in the command above.

So if the last number in uname -r is 26 (or 28, or even 25), then it's safe to run the above command. Enter your password when prompted, and type y when asked. This will show a bunch of lines, and will eventually go back to the command prompt (in your case, matty@matty-G41M-ES2L:~$), hopefully without errors. When it's done, do df -h and look at the last line, the one that starts with /dev/sda1. You should find that it now has more space, and that the percentage used is less than 100% like it was before. You can now proceed with your update again.


You can install Ubuntu-Tweak.To install follow the following steps:

Open the terminal. Add the required repository with the command:

sudo add-apt-repository ppa:tualatrix/ppa

Update the software list with the command:

sudo apt-get update

Finally, install Ubuntu Teak with the command:

sudo apt-get install ubuntu-tweak

After that, open dash and type "ubuntu tweak".

And then go to janitor tab and select Apps , Personal and System check boxes and click clean button at bottom right.


A quick way to remove all unused kernels and headers (excluding the current running kernel) has been pointed out by @Lekensteyn in his answer to the question How do I free up more space in /boot?:

sudo apt-get purge $(dpkg -l linux-{image,headers}-"[0-9]*" | awk '/ii/{print $2}' | grep -ve "$(uname -r | sed -r 's/-[a-z]+//')") 

This should free up enough space for you to upgrade.

Tags:

Upgrade

Apt