Sunday 23 September 2012

Ubuntu 10.04 - removing multiple grub boot options

Intro

During its lifetime, Ubuntu gets series of kernel updates. At each kernel update, grub (v1.98) is updated in order to allow the user to boot to those kernel versions. After 2-3 updates grub boot menu gets really congested. For those who do not want all the boot possibilities here is how to clean that up.

The idea

The idea is to uninstall previous kernel/headers versions from our system. Not only will that free up some disk space, but also remove appropriate boot options. So no longer will we be able to boot into previous kernels. If that is something you cannot afford, stop right here. The intention is to leave the newest kernel only. This is how to do it.

Searching for currently installed kernel versions

petrelli@laps:~$ dpkg -l | grep linux-headers-*
ii  linux-headers-2.6.32-42                   2.6.32-42.96                                    Header files related to Linux kernel version
ii  linux-headers-2.6.32-42-generic           2.6.32-42.96                                    Linux kernel headers for version 2.6.32 on x
ii  linux-headers-2.6.32-43                   2.6.32-43.97                                    Header files related to Linux kernel version
ii  linux-headers-2.6.32-43-generic           2.6.32-43.97                                    Linux kernel headers for version 2.6.32 on x
ii  linux-headers-generic                     2.6.32.43.50                                    Generic Linux kernel headers

and


petrelli@laps:~$ dpkg -l | grep linux-image*
rc  linux-image-2.6.32-42-generic             2.6.32-42.96                                    Linux kernel image for version 2.6.32 on x86
ii  linux-image-2.6.32-43-generic             2.6.32-43.97                                    Linux kernel image for version 2.6.32 on x86
ii  linux-image-generic                       2.6.32.43.50                                    Generic Linux kernel image

So, current kernel version is 2.6.32.43, there is only one older kernel: 2.6.32.42.

Removing obsolete kernel(s)

petrelli@laps:~$ sudo apt-get remove linux-headers-2.6.32-42 linux-headers-2.6.32-42-generic

This should free over 100 MB from your disk. Optionally, you can later run:

petrelli@laps:~$ sudo apt-get autoremove

Updating grub

petrelli@laps:~$ sudo update-grub2

Right now the grub menu should point only at Ubuntu using the newest kernel version.


No comments: