Clean Up the New Ubuntu Grub2 Boot Menu

Ubuntu adopted the new version of the Grub boot manager in version 9.10, getting rid of the old problematic menu.lst. Today we look at how to change the boot menu options in Grub2.

Grub2 is a step forward in a lot of ways, and most of the annoying menu.lst issues from the past are gone. Still, if you’re not vigilant with removing old versions of the kernel, the boot list can still end up being longer than it needs to be.

sshot-1

Note: You may have to hold the SHIFT button on your keyboard while booting up to get this menu to show. If only one operating system is installed on your computer, it may load it automatically without displaying this menu.

Remove Old Kernel Entries

The most common clean up task for the boot menu is to remove old kernel versions lying around on your machine.

In our case we want to remove the 2.6.32-21-generic boot menu entries. In the past, this meant opening up /boot/grub/menu.lst…but with Grub2, if we remove the kernel package from our computer, Grub automatically removes those options.

To remove old kernel versions, open up Synaptic Package Manager, found in the System > Administration menu.

When it opens up, type the kernel version that you want to remove in the Quick search text field. The first few numbers should suffice.

sshot-2

For each of the entries associated with the old kernel (e.g. linux-headers-2.6.32-21 and linux-image-2.6.32-21-generic), right-click and choose Mark for Complete Removal.

sshot-3

Click the Apply button in the toolbar and then Apply in the summary window that pops up. Close Synaptic Package Manager.

The next time you boot up your computer, the Grub menu will not contain the entries associated with the removed kernel version.

sshot-4

Remove Any Option by Editing /etc/grub.d

If you need more fine-grained control, or want to remove entries that are not kernel versions, you must change the files located in /etc/grub.d.

sshot-7

/etc/grub.d contains files that hold the menu entries that used to be contained in /boot/grub/menu.lst. If you want to add new boot menu entries, you would create a new file in this folder, making sure to mark it as executable.

If you want to remove boot menu entries, as we do, you would edit files in this folder.

If we wanted to remove all of the memtest86+ entries, we could just make the 20_memtest86+ file non-executable, with the terminal command

sudo chmod –x 20_memtest86+

sshot-10

Followed by the terminal command

sudo update-grub

sshot-11

Note that memtest86+ was not found by update-grub because it will only consider executable files.

However, instead, we’re going to remove the Serial console 115200 entry for memtest86+…

Open a terminal window Applications > Accessories > Terminal. In the terminal window, type in the command:

gksudo gedit /etc/grub.d/20_memtest86+

The menu entries are found at the bottom of this file.

sshot-5

Delete the menu entry for serial console 115200.

Note: Commenting out the menu entry will not work — it must be deleted. Copy it to a different file if you’re worried you might need it later.

sshot-xx

Save and close this file. In the terminal window you opened, enter in the command

sudo update-grub

Note: If you don’t run update-grub, the boot menu options will not change!

sshot-8

Now, the next time you boot up, that strange entry will be gone, and you’re left with a simple and clean boot menu.

sshot-9

Conclusion

While changing Grub2’s boot menu may seem overly complicated to legacy Grub masters, for normal users, Grub2 means that you won’t have to change the boot menu that often. Fortunately, if you do have to do it, the process is still pretty easy.

For more detailed information about how to change entries in Grub2, this Ubuntu forum thread is a great resource. If you’re using an older version of Ubuntu, check out our article on how to clean up Ubuntu grub boot menu after upgrades.

Trevor is our resident Linux geek, but always keeps his eyes open for neat Windows tricks too.