Upgrading a new kernel.. and removing old ones in Ubuntu. —

I use Kubuntu 10.04.. which is begotten by Debian, and this should work on all Debian based systems.

Upgrading to the next available kernel is easy.. in a command line as root.. you type
sudo apt-get update
to update your list of available packages in the repositories.. then you type
sudo apt-get dist-upgrade
Simple enough right?

Well after each upgrade you will reboot and see that alas.. Grub can still boot into your old kernels.. but after 1 good boot I say that unless you just jack up your kernel a lot.. keeping only the most recent working kernel is good enough.. so..

How to remove all but your most recent kernel.

You need to know what NOT to remove.. so after you’ve upgraded your kernel or you are happy running what you got.. you type this.

uname -a
This will show you your current kernel version.. mine tells me:

Linux beater 2.6.32-24-generic #41-Ubuntu SMP Thu Aug 19 01:12:52 UTC 2010 i686 GNU/Linux

In order to see what kernels we have installed we run

dpkg -l | grep linux-headers-*
Which for me returned:

ii linux-headers-2.6.32-21 2.6.32-21.32 Header files related to Linux kernel version
ii linux-headers-2.6.32-21-generic 2.6.32-21.32 Linux kernel headers for version 2.6.32 on x
ii linux-headers-2.6.32-24 2.6.32-24.41 Header files related to Linux kernel version
ii linux-headers-2.6.32-24-generic 2.6.32-24.41 Linux kernel headers for version 2.6.32 on x
ii linux-headers-generic Generic Linux kernel headers

So since I know that 2.6.32-24 is my current, then I need to remove 2.6.32-21..

and to do that I type

sudo apt-get remove linux-headers-2.6.32-21 linux-headers-2.6.32-21-generic

Rinse / Repeat if you have multiple old kernels.

Categorised as: Linux

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.