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 3.13.0-30-generic
As you can see I have the
Find installed kernels.
Next you need to list all the installed kernels
$ dpkg --list | grep linux-image
I had the following:
linux-image-188.8.131.52-generic (184.108.40.206.50) linux-image-220.127.116.11-generic (18.104.22.168.53) linux-image-22.214.171.124-generic (126.96.36.199.47) linux-image-188.8.131.52-generic (184.108.40.206.55) linux-image-extra-220.127.116.11-generic (18.104.22.168.50) linux-image-extra-22.214.171.124-generic (126.96.36.199.53) linux-image-extra-188.8.131.52-generic (184.108.40.206.47) linux-image-extra-220.127.116.11-generic (18.104.22.168.55)
A recommendation from askubuntu.com says to alway keep at least two kernels. So I will remove
22.214.171.124-generic while keeping
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-126.96.36.199-generic
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.