Not enough disk space to update linux

Thu, 05/14/2015 - 18:04

I sometimes get an error from the package manager when trying to update my system. The error reports that I don't have enough disk space. I'm running Xubuntu 14.04. Here's the solution I found.


The reason I get the error is that the update contain a new linux kernel, which needs to be install in the /boot partition. This partition is relvatively small and the old kernels are not deleted automatically.


2017-01-13 Update: I'm not sure when this feature became available but om my Ubuntu 16.04 I can now do sudo apt autoremove which will remove old unused linux headers.

There are two solutions. You can increase the /boot partition or you can delete the old kernels. Increasing the partition is not a good idea. Either you make it too small and you will soon run into this problem again, or you end up taking disk space away from other partitions, such as you home directory (where you probably keep your images and music, etc.).

The second solution is what I'm doing. Here's how. For the last part I assume you know how to use the terminal.

Find the current kernel.

First you need to know your current kernel. If you use conky it might be listed there. If not you can use this command:

$ uname -r

As you can see I have the 3.13.0-30-generic kernel.

Find installed kernels.

Next you need to list all the installed kernels

$ dpkg --list | grep linux-image 

I had the following:

linux-image- (
linux-image- (
linux-image- (
linux-image- (
linux-image-extra- (
linux-image-extra- (
linux-image-extra- (
linux-image-extra- (

A recommendation from says to alway keep at least two kernels. So I will remove and while keeping and

Removing a kernel.

To remove a kernel you only need to remove the linux-image-* and the associated linux-image-extra-* will also be removed. To do this use this command:

$ sudo apt-get purge linux-image- 

Final comments

You can find different one liners that will find all the old kernels and remove them automatically. These are great, but you have to be cautious when executing commands you found online. You shouldn't blindly trust everything. At least try to understand the commands before executing them. For example you can use the man pages by typing for example man dpkg to check what it does.

Best of luck.