Remove Old Kernel Images on Ubuntu

After many kernel upgrades, the /boot partition might run out of spaces. Here is how to remove some older kernel images.

Method 1 - Use Synaptic Package Manager

This should be the easiest way. Start your Synaptic Package Manager, and search for 'linux-image' and 'linux-header'. Uninstall the images and headers that you don't want anymore.

Method 2 - Use apt-get

If you prefer command line operation, this is how you can do it:

# dpkg --list 'linux-image*'
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Installed/Config-files/Unpacked/Failed-config/Half-installed
|/ Err?=(none)/Hold/Reinst-required/X=both-problems (Status,Err: uppercase=bad)
||/ Name                                    Version                                 Description
+++-=======================================-====================
linux-image                             <none>                                  (no description available)
un  linux-image-2.6                         <none>                          (no description available)
ii    linux-image-2.6.15-26-386               2.6.15-26.47            Linux kernel image for version ...
ii    linux-image-2.6.15-27-386               2.6.15-27.50            Linux kernel image for version ...
ii    linux-image-2.6.15-27-686               2.6.15-27.50                        

Next, check if there are old kernel header files that you wish to purge:

# dpkg --list 'linux-header*'

Now remove some older kernel images and their headers:

# apt-get remove linux-image-2.6.15-27-386 linux-headers-2.6.15-27-386

Verification

Now if you call "df -h" you shall see more space available in /boot.

Also, open your /boot/grub/menu.lst and see if the entries for the deleted images still exist in the GRUB config file. They should have been removed. If not, you can manually remove them.