Purging Old Kernels on Ubuntu

Problem

Old kernel images are not automatically removed during apt-get upgrade procedures. This can result in wasted disk space in /boot, and in some cases can end up filling /boot and preventing further updates to the kernel.

Solution

Removing old kernels is straightforward, as shown in this excerpt from askubuntu.com

Open terminal and check your current kernel:

uname -r

DO NOT REMOVE THIS KERNEL!

Next, type the command below to view / list all installed kernels on your system.

dpkg --list | grep linux-image

Find all the kernels that lower than your current kernel. When you know which kernel to remove, continue below to remove it. Run the commands below to remove the kernel you selected.

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

Note

You can use bash’s brace substitution to refer to a series of kernel versions. For example:

sudo apt-get purge linux-image-2.6.32-4{0..5}-server

Reboot your system.

If you can’t run update because the partition is full, then manually removing one of the old images from /boot will generally free up enough space.