Not very recently, I decided to upgrade my bootloader from GRUB to GRUB 2. The reason I tried doing this was-
Ubuntu 9.10 Karmic Koala is just about to be released. It uses GRUB 2 as the bootloader by default. Although when you upgrade from Jaunty to Karmic, your bootloader won’t be upgraded, curiosity can be tough to handle at times. I feel confident that I know my way around GRUB (and trust the great community support) and can handle any bootloader related problems so I decided to go for the upgrade. Here’s a warning before you try doing anything with your bootloader, upgrading a bootloader is risky and can get messed up at times.
This post is specific to Ubuntu, and some of the parts are specific to Ubuntu 9.04 and later versions.
Installing GRUB 2
It is suggested that you test GRUB 2 before replacing your GRUB installation completely with GRUB 2. You can test GRUB to by installing it as a chainloaded sub-bootloader if you are using Ubuntu 9.04. To get started with testing and installation, open a terminal and run this command-
sudo apt-get install grub-pc
Select “Yes” at the “Chainload from menu.lst” prompt and at the “Linux command line:” prompt just press enter. This should install GRUB 2 and modify menu.lst accordingly.
If you are using Ubuntu Jaunty, you will face a bug which modifies the menu.lst incorrectly. So most probably you will face a problem when you try to boot using GRUB 2 chainloaded. To correct this problem, when the GRUB menu appears, at the “Chainload into Grub 2” menu item, press ‘e’ to edit the configuration. Press ‘e’ a second time to edit the top boot line and change:
root xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
to
uuid xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
press Enter after making the change and press b to boot GRUB 2. If everything goes fine, you should be able to boot using GRUB 2 and you are ready to replace GRUB completely by GRUB 2 as the main bootloader. To do that, use the command-
sudo upgrade-from-grub-legacy
IMPORTANT: Make sure that you hit the space bar to select /dev/sda when it asks you the location where grub needs to be installed. If you hit enter on this screen it will not install grub on /dev/sda and your system will not boot.
For any other kind of troubleshooting related to GRUB 2 problems, you can check out this Ubuntu wiki page.
Editing the GRUB 2 Menu
After I installed GRUB 2, I started taking a look around its files. Editing the GRUB menu was really simple. You just needed to edit the /boot/grub/menu.lst file. GRUB 2 is a bit different in this regard. The GRUB 2 configuration file is /boot/grub/grub.cfg. This file is not supposed to be edited directly. It is an automatically generated file. You can actually make out from the comments what part of grub.cfg is generated by which file. The files that are used to generate the grub.cfg file are those located in the /etc/grub.d folder and the /etc/default/grub file. Editing these files isn’t as simple as editing menu.lst. You need to have some programming knowledge to understand these files. But you don’t need to worry, I’ll be posting ways to implement some common menu.lst edits in grub.cfg using the GRUB 2 files in some other posts.
My first experience of working with GRUB 2 was fun. Had a good time experimenting with stuff. You can also experiment a bit but always remember to keep backups before editing any file and playing around with your bootloader can be dangerous and is not recommended.
[…] This method will only work with the GRUB legacy bootloader. If you are using GRUB 2, wich is very likely after the release of Ubuntu 9.10 Karmic Koala, you should have a look at part […]
[…] how you can solve this issue by making an edit in the /boot/grub/menu.lst file. But recently, I upgraded my bootlaoder to GRUB 2. Many people would eventually do so in the near future. As I’ve mentioned in that post, […]