Responding to a LinkedIn discussion asking on how to clean up the boot menu and remove old or obsolete kernel packages, I have posted this quick set of steps I used today and from time to time to execute this task.
With the GUI, there are a lot of options, with the most obvious being to use Synaptic . Since I learned this prior to the various GUIs, I have really not gotten away from the good old terminal window, which is the basis for the information here.
Overview of the steps:
- Determine the running kernel package version
- Review the installed kernel packages
- Become Root and remove older and unused package versions
Determine the running kernel package version:
imac@n8-laptop:~$ uname -a
Linux n8-laptop.ianbmacdonald.com 2.6.28-15-generic #52-Ubuntu SMP Wed Sep 9 10:48:52 UTC 2009 x86_64 GNU/Linux
imac@n8-laptop:~$
I can tell that I am running the 2.6.28-15 kernel version, and that this is package release #52 for the Ubuntu Jaunty kernel. Using uname -v and uname -r in isolation shows these specifics independently.
Determine what kernel packages are currently installed:
imac@n8-laptop:~$ dpkg -l | grep linux-image
ii linux-image-2.6.28-13-generic 2.6.28-13.45 Linux kernel image for version 2.6.28 on x86
ii linux-image-2.6.28-14-generic 2.6.28-14.47 Linux kernel image for version 2.6.28 on x86
ii linux-image-2.6.28-15-generic 2.6.28-15.52 Linux kernel image for version 2.6.28 on x86
ii linux-image-generic 2.6.28.15.20 Generic Linux kernel image
imac@n8-laptop:~$
Here, looking at the second column, I can see that in addition to the 2.6.28-15.52 version I am currently running, I also have two older versions (2.6.28-13.45, 2.6.28-14.47) installed. The last package is a virtual package that points to the current official package release. If you installed this virtual package, it would by default install linux-image-2.6.28-15-generic today. You can see that its version hints this fact.
Become root, and remove the older unused kernel image packages:
imac@n8-laptop:~$ sudo -i
[sudo] password for imac:
root@n8-laptop:~# apt-get remove linux-image-2.6.28-13-generic linux-image-2.6.28-14-generic –purge
Reading package lists… Done
Building dependency tree
Reading state information… Done
The following packages will be REMOVED:
linux-image-2.6.28-13-generic* linux-image-2.6.28-14-generic* linux-restricted-modules-2.6.28-13-generic* linux-restricted-modules-2.6.28-14-generic*
0 upgraded, 0 newly installed, 4 to remove and 0 not upgraded.
After this operation, 230MB disk space will be freed.
Do you want to continue [Y/n]?
… Truncated Output …
I note that I like to use --purge to remove all related configuration when I am permanently removing packages. Without this purge, the package management system actually retains information about the previously installed packages. Packages that have not been purged actually show up in the previous command with an “rc” in the first column where you see an “ii” in the output from dpkg -l above. It is also worth noting that the package management system takes care of removing dependant packages, updating out-of-kernel modules like nvidia display drivers and performing some post-remove actions like updating the Grub boot menu. The output above is truncated, and does not show all this additional activity and output. Once this is complete the boot menu will no longer present options for booting these older kernel versions. I expect that future versions of Ubuntu will implement events that automatically push this type of clean-up activity forward to the user for acknowledgement in the GUI. As with everything, I am sure there is a nice GUI way of doing this, however I have have been executing these commands for over a decade on various Debian-based servers and desktops, so unfortunately I am not familiar with the latest simple GUI way of doing things.
A note on linux kernels in debian based systems (Ubuntu):
It is important to note that in the life of a distribution (i.e. Ubuntu Jaunty/9.04) typically there is only one major version (2.6.28 for Jaunty), a number of kernel package versions (2.6.28-13, 2.6.28-14, etc.) and then releases of each of these kernel packages (this number is incremented across all versions and is appended after the last dot, 52 in today’s current release - 2.6.28-15.52).
Looking at the changelog for the current kernel package (2.6.28-15) shows change information that covers all the release/version history for the current distribution, and sheds some light on when/why multiple kernel image packages show up, and create these additional boot menu items. Below is the the current kernel package changelog, and you can see that five kernel package updates were actually all to the 2.6.28-15 package version, so these would not have generated new menu items, and would have simply been updates to the same kernel image package.
This is why today I feel comfortable removing all the 2.6.28-13 and 2.6.28-14 packages, as they are not the *previous two versions* … but rather much older versions that had separate kernel image packages. (In this case they are three to four months old, as seen by the dates in the complete chaneglog) The only time it might be prudent to keep one of your older kernel packages, IMHO, is when you are transitioning to a new version, i.e. 2.6.28-14 to 2.6.28-15, which is also the point at which you would see a new boot menu item appear. Generally this is also when you might get excited for some new hardware support if your current cutting-edge laptop had some unsupported components.
imac@n8-laptop:/$ zcat /usr/share/doc/linux-image-2.6.28-15-generic/changelog.Debian.gz | grep "(2.6.28"
linux (2.6.28-15.52) jaunty-proposed; urgency=low
linux (2.6.28-15.51) jaunty-proposed; urgency=low
linux (2.6.28-15.50) jaunty-proposed; urgency=low
linux (2.6.28-15.49) jaunty-security; urgency=low
linux (2.6.28-15.48) jaunty-proposed; urgency=low
linux (2.6.28-14.47) jaunty-security; urgency=low
linux (2.6.28-13.45) jaunty-security; urgency=low
linux (2.6.28-13.44) jaunty-proposed; urgency=low
linux (2.6.28-12.43) jaunty-proposed; urgency=low
linux (2.6.28-11.42) jaunty; urgency=low
linux (2.6.28-11.41) jaunty; urgency=low
linux (2.6.28-11.40) jaunty; urgency=low
linux (2.6.28-11.39) jaunty; urgency=low
linux (2.6.28-11.38) jaunty; urgency=low
linux (2.6.28-11.37) jaunty; urgency=low
linux (2.6.28-11.36) jaunty; urgency=low
linux (2.6.28-11.35) jaunty; urgency=low
linux (2.6.28-11.34) jaunty; urgency=low
linux (2.6.28-10.33) jaunty; urgency=low
linux (2.6.28-10.32) jaunty; urgency=low
linux (2.6.28-9.31) jaunty; urgency=low
linux (2.6.28-9.30) jaunty; urgency=low
linux (2.6.28-9.29) jaunty; urgency=low
linux (2.6.28-8.28) jaunty; urgency=low
linux (2.6.28-8.27) jaunty; urgency=low
linux (2.6.28-8.26) jaunty; urgency=low
linux (2.6.28-8.25) jaunty; urgency=low
linux (2.6.28-8.24) jaunty; urgency=low
linux (2.6.28-8.23) jaunty; urgency=low
linux (2.6.28-8.22) jaunty; urgency=low
linux (2.6.28-8.21) jaunty; urgency=low
linux (2.6.28-7.20) jaunty; urgency=low
linux (2.6.28-7.19) jaunty; urgency=low
linux (2.6.28-7.18) jaunty; urgency=low
linux (2.6.28-6.17) jaunty; urgency=low
linux (2.6.28-6.16) jaunty; urgency=low
linux (2.6.28-5.15) jaunty; urgency=low
linux (2.6.28-5.14) jaunty; urgency=low
linux (2.6.28-5.13) jaunty; urgency=low
linux (2.6.28-5.12) jaunty; urgency=low
linux (2.6.28-4.11) jaunty; urgency=low
linux (2.6.28-4.10) jaunty; urgency=low
linux (2.6.28-4.9) jaunty; urgency=low
linux (2.6.28-4.8) jaunty; urgency=low
linux (2.6.28-4.7) jaunty; urgency=low
linux (2.6.28-4.6) jaunty; urgency=low
linux (2.6.28-4.5) jaunty; urgency=low
linux (2.6.28-3.4) jaunty; urgency=low
linux (2.6.28-2.3) jaunty; urgency=low
linux (2.6.28-2.2) jaunty; urgency=low
linux (2.6.28-1.1) jaunty; urgency=low
This information is also easily viewed online.












