Saturday, March 24, 2012

Removing Old Linux Kernel Entries from GRUB2 Menu in Ubuntu 11.10 & Fedora


Using Synaptic Package Manager

The boot loader for Ubuntu 11.10 is indeed GRUB (GRand Unified Bootloader), like all Linux distros. It's been a long time since we are acquainted with GRUB. Ubuntu 9.10 onwards it has replaced LILO (LInux LOader) and adeptly performs its task of multiple booting operating systems including Windows. Even we can boot multiple kernels within
a single operating system. Till now GRUB is still the default boot loader in Linux.

My Grub Bootloader is flooded with the old linux-kernels. It is clearly evident from the below shown screenshot. Below mentioned command helps in finding all the kernels in the operating system.

$ dpkg -l | grep linux-image


My present working linux kernel version is 3.0.0-16.29. Now I can remove all the old linux kernels that are not in use now and are unnecessarily taking extra space on my hard disk. Since the old kernels are not much of concern to my operating system, hence doing this will also not include old linux kernels while GRUB2 update. As I said there wont be any problem because of this action.

The other linux-images that I found on my system other than my current kernel (3.0.0-16.28) were 3.0.0-12.20, 3.0.0-13.22, 3.0.0-14.23 & 3.0.0-15.26.

The procedure to remove the old linux kernel images is as follows :

Using Synaptic Package Manager
1. Go to Dash and search for 'Synaptic Package Manager'

2. In Quick filter search for 'linux-image'.

3. Scroll to find the list of kernels which have green colored check box which indicates that they are already installed. Whereas the green check box with star mark indicates the current version in use. The "latest version" is likely to be the default one at the top of the list, with the most up-to-date number.


4. Now to remove the old kernel versions we need to click on the check box and a drop down menu will appear. Click on 'Mark for Complete Removal'.

5. Click on the Apply icon in the menu bar

6. Finally reboot the computer and check whether everything is fine. Phew!!!

7. Re-run the synaptic package manager to check again for the linux kernel images.

8. Run the below command to update GRUB2
$ sudo update-grub2

Using Ubuntu-tweak

The most easiest and fastest method is using Ubuntu-tweak. Ubuntu-tweak package is not available in the standard repositories of Ubuntu 11.10. To install we need to use the author's PPA as shown below.

$ sudo add-apt-repository ppa:tualatrix/ppa
$ sudo apt-get update
$ sudo apt-get install ubuntu-tweak

Run Ubuntu-tweak application using the below mentioned command
$ ubuntu-tweak
Or we can also find the package through Dash and run it.

On the left pane you will find 'Old Kernel', select it and you will find all the entries related to it in the right pane.


Select all the old linux-images that you want to remove, click on 'Clean' and that is it. You will notice that ubuntu-tweak is intelligent enough to not display the current working linux image.



Quick tip for Fedora Users
Type into terminal the below command
$ su -c 'package-cleanup --oldkernels'


NOTE: While we remove the old kernels we should always keep two latest kernels other than the current working kernel. Doing this will keep us on the safer side in case of any damage happens to the current working kernel of your operating system. Moreover it will ensure us a boot using the previous kernel.


Enjoy.

No comments:

Post a Comment