I got this message:

not enough free disk space.... The upgrade needs a total of 31.8 M free space on disk '/boot'. Please free at least an additional 31.8 M of disk space on '/boot'. Empty your trash and remove temporary packages of former installations using 'sudo apt-get clean'

I'm really not that good of a user and have very little experience with Linux. I'd like some help with how to resolve this error.


I think for starters you can run the command that the error message is suggesting you run in a terminal. Assuming you're running Ubuntu.

  1. open terminal window: Ctrl + Alt + T
  2. type the command: sudo apt-get clean
  3. provide your password when prompted

You seem to be using Ubuntu. Ubuntu often keeps back the older kernel packages after an upgrade.
All these kernels are stored in your /boot directory which is often kept very small.

You can check the free space you have left, by running:

$ df -h 

In order to upgrade, you need to remove a few of your older kernels. To do this, first identify the kernel you are currently running:

$ uname -r

This will give you an output like:


Next, list all the kernels that reside in your /boot directory:

$ ls /boot | grep vmlinuz 

Now, you must uninstall all but the most recent (The one with the largest number) kernels. To do this, first list all the packages that were installed for that kernel:

dpkg -l | grep ^ii | grep 2.6.28-15 | awk -F' ' '{ print $2 }'

Where 2.6.28-15 is the version of the kernel I am uninstalling. This gives a list like:


Now to remove these:

$ sudo aptitude remove linux-headers-2.6.28-15 linux-headers-2.6.28-15-generic linux-image-2.6.28-15-generic linux-restricted-modules-2.6.28-15-generic

Or, you could use the following one-liner:

# dpkg -l linux-* | awk '/^ii/{ print $2}' | grep -v -e `uname -r | cut -f1,2 -d"-"` | grep -e [0-9] | xargs sudo apt-get -y purge

WARNING: Always be wary of commands you find online. The above one-liner is not my own and I take no responsibility for it. Follow the steps given above and you should be safe enough.

  • The one-liner at the end looks reasonably safe to me. It can be made another bit safer by replacing the -y parameter to apt-get with --simulate to get an output detailing what would be done. Once satisfied that it is safe, --simulate can be removed for an actual run. – a CVn Apr 10 '13 at 11:11
  • 1
    It looks safe to me too. I would not post anything without understanding it first. However, I am always a little wary about automating such things. – darnir Apr 10 '13 at 13:47
  • We are in agreement about that. – a CVn Apr 10 '13 at 13:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.