Trimming list of OS in Ubuntu/Kubuntu Hardy boot loader (grub)

If you have been upgrading ubuntu/kubuntu for several times, you will notice that the list in the boot loader increases.  By default Kubuntu keeps the previous Linux kernel for you to boot. So when you have upgraded the linux kernel, the old kernels will stay there in the boot loader.

So if you have windows, you will see a list of kernels version and at the end of the list is the other operating system, windows.

If you want to trim the list of OS displayed by the boot loader, this is what you need to do.

First back up the menu.lst file:

% sudo cp /boot/grub/menu.lst /boot/grub/menu.lst.old

Then edit the menu.lst file

%sudo vi /boot/grub/menu.lst

comment those OS you do not want to display in Grub by adding “#” at the beginning of the line.  You will find the list of the OS most probably at the end of the file.

Below is what I have in my system. As you can see I comment all except my windows, memtest, and the latest kernel version together with its recovery mode. After reboot, you will see only these list in grub bootloader.

%cat menu.lst file

….

## ## End Default Options ##

title           Ubuntu 8.04, kernel 2.6.24-19-generic
root            (hd0,4)
kernel          /boot/vmlinuz-2.6.24-19-generic root=UUID=xxx ro quiet splash
initrd          /boot/initrd.img-2.6.24-19-generic
quiet

title           Ubuntu 8.04, kernel 2.6.24-19-generic (recovery mode)
root            (hd0,4)
kernel          /boot/vmlinuz-2.6.24-19-generic root=UUID=xxx ro single
initrd          /boot/initrd.img-2.6.24-19-generic

#title          Ubuntu 8.04, kernel 2.6.24-18-generic
#root           (hd0,4)
#kernel         /boot/vmlinuz-2.6.24-18-generic root=UUID=xxx ro quiet splash
#initrd         /boot/initrd.img-2.6.24-18-generic
#quiet

#title          Ubuntu 8.04, kernel 2.6.24-18-generic (recovery mode)
#root           (hd0,4)
#kernel         /boot/vmlinuz-2.6.24-18-generic root=UUID=xxx ro single
#initrd         /boot/initrd.img-2.6.24-18-generic

#title          Ubuntu 8.04, kernel 2.6.24-17-generic
#root           (hd0,4)
#kernel         /boot/vmlinuz-2.6.24-17-generic root=UUID=xxx ro quiet splash
#initrd         /boot/initrd.img-2.6.24-17-generic
#quiet

#title          Ubuntu 8.04, kernel 2.6.24-17-generic (recovery mode)
#root           (hd0,4)
#kernel         /boot/vmlinuz-2.6.24-17-generic root=UUID=xxx ro single
#initrd         /boot/initrd.img-2.6.24-17-generic

#title          Ubuntu 8.04, kernel 2.6.24-16-generic
#root           (hd0,4)
#kernel         /boot/vmlinuz-2.6.24-16-generic root=UUID=xxx ro quiet splash
#initrd         /boot/initrd.img-2.6.24-16-generic
#quiet

#title          Ubuntu 8.04, kernel 2.6.24-16-generic (recovery mode)
#root           (hd0,4)
#kernel         /boot/vmlinuz-2.6.24-16-generic root=UUID=xxx ro single
#initrd         /boot/initrd.img-2.6.24-16-generic

#title          Ubuntu 8.04, kernel 2.6.22-14-generic
#root           (hd0,4)
#kernel         /boot/vmlinuz-2.6.22-14-generic root=UUID=xxx ro quiet splash
#initrd         /boot/initrd.img-2.6.22-14-generic
#quiet

#title          Ubuntu 8.04, kernel 2.6.22-14-generic (recovery mode)
#root           (hd0,4)
#kernel         /boot/vmlinuz-2.6.22-14-generic root=UUID=xxx ro single
#initrd         /boot/initrd.img-2.6.22-14-generic

#title          Ubuntu 8.04, kernel 2.6.20-16-generic
#root           (hd0,4)
#kernel         /boot/vmlinuz-2.6.20-16-generic root=UUID=xxx ro quiet splash
#initrd         /boot/initrd.img-2.6.20-16-generic
#quiet

#title          Ubuntu 8.04, kernel 2.6.20-16-generic (recovery mode)
#root           (hd0,4)
#kernel         /boot/vmlinuz-2.6.20-16-generic root=UUID=xxx ro single
#initrd         /boot/initrd.img-2.6.20-16-generic

#title          Ubuntu 8.04, kernel 2.6.20-15-generic
#root           (hd0,4)
#kernel         /boot/vmlinuz-2.6.20-15-generic root=UUID=xxx ro quiet splash
#initrd         /boot/initrd.img-2.6.20-15-generic
#quiet

#title          Ubuntu 8.04, kernel 2.6.20-15-generic (recovery mode)
#root           (hd0,4)
#kernel         /boot/vmlinuz-2.6.20-15-generic root=UUID=xxx ro single
#initrd         /boot/initrd.img-2.6.20-15-generic

title           Ubuntu 8.04, memtest86+
root            (hd0,4)
kernel          /boot/memtest86+.bin
quiet

### END DEBIAN AUTOMAGIC KERNELS LIST

# This is a divider, added to separate the menu items below from the Debian
# ones.
title           Other operating systems:
root

# This entry automatically added by the Debian installer for a non-linux OS
# on /dev/sda2
title           Microsoft Windows XP Professional
root            (hd0,1)
savedefault
makeactive
chainloader     +1

Advertisements

2 Responses

  1. Cleaner way is to remove packages containing the unnecessary kernel modules. for example I removed the old one containing this: “2.6.20-16” and this “2.6.24-17” in packages manager. It also cleans the list.

  2. Thanks Vitezslav Valka

    This is a better solution indeed especially if we don’t want to keep the older kernel.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: