Wednesday, 21 September 2011

How-to: Remove Old Linux Kernel, Clean Up Boot Menu

Usually when Linux updates to a new Linux kernel version, the old one is left behind and your boot menu gets longer. Once you're sure your new Linux kernel is working and stable, you can safely remove the old kernel versions and clean up the boot menu. 

Do this with care and attention removal of the current running kernel will render your system un-bootable. I know, I've done it!

Run the System Monitor (sysmon) where the system tab will tell you the version number of the current running kernel. In a Terminal session, the command
uname -r
returns the same information; on my Ubuntu machine it's 2.6.38-8-generic.

Next, go to System > Administration > Synaptic
 
In the lower left panel, choose Status then select 'Installed' from the filter list. This narrows down your candidate list to those installed.
 
Enter the current kernel version number (e.g. 2.6.38) in the Search box. You wil get a filtered list based on your latest kernel version - mine is 2.6.38-11-generic).
 
Right-click the items with smaller sub-version number (e.g. 2.6.38-10) for older Linux kernels and select Mark for Complete Removal. The complete set of files to be removed for older kernel versions will most likely include linux-headers-2.6.38-10, linux-headers-2.6.38-10-generic and linux-image-2.6.38-10-generic.
 
Select Apply from the top panel.
 
Select Apply again when the confirmation dialog pops-up to confirm removal of the marked packages. The old versions will drop out of the boot menu when it is cleaned up automatically after the old kernel version is removed. RC