[HOW-TO] Remove old kernels from Ubuntu

The Linux kernel is not updated very often to require removing old versions regularly. However, when a new version is released, sometimes you may want to remove the old version so as to save on the disk space used. I normally employ the following method when removing old kernels because it is quite thorough and can be mostly accomplished through a terminal window. If you are accustomed to going through the Synaptic Package Manager and manually marking old versions for removal, you may want to try this alternative. However, before you start cleaning, you need to be aware of the all kernel versions that are currently installed on Ubuntu. The last thing you want to do is remove something unintentionally and be faced with an unbootable system.

Go to System > Administration > Synaptic Package Manager and perform a search for linux-image. From the search results identify those installed items with linux-image-2.6.xx-xx-* in the file name. The screenshot shows three kernel versions currently installed: 2.6.28-11, 2.6.28-13 and 2.6.28-14. Take note of these.

Synaptic Package Manager

Launch the terminal and run the following command to verify the currently-installed kernel version.

uname -r

The output from this command should confirm what you found in the Synaptic Package Manager. In the screenshot above version 2.6.28-14 is the kernel currently being utilized by Ubuntu. Take note of it. We do not want to remove that one! Note that your latest version may differ.

In the same terminal window execute the following command after modifying it with the kernel version you wish to remove.

sudo apt-get remove --purge 2.6.2x-yz-*

As an example, if I wanted to remove kernel 2.6.28-11, I would enter this command.

sudo apt-get remove --purge 2.6.28-11-*

Allow the cleanup to run. Your Grub menu will also be automatically updated to reflect the removed kernel.

That’s it! Simple, wasn’t it? All you have to do now is repeat the steps for other old kernels that you wish to remove.