20 December 2009

Making Grub2 Nice

Or how I learned to stop worrying and make my boot menu easier to use.

Alright folks, I've been meaning to write this one for a while. Ubuntu/Kubuntu 9.10 decided to switch to the GRand Unified Bootloader version 2. This is great feature-wise and all, but now you have to relearn how to edit the config files!

I've done some studying and found out how to do what simple things I used to do, make the boot menu simple.

So, Open the run command ("Alt F2"/"Alt Space"/Right click on desktop "Run Comand...") and type kdesudo kate (or on Ubuntu gksu gedit)
Let's open up /boot/grub/grub.cfg . This file is only a reference. Let's also make a new file. Let's save it to /etc/grub.d/09_custom .

Let's add some text to 09_custom :

exec tail -n +3 $0
# This file provides an easy way to add custom menu entries. Simply type the
# menu entries you want to add after this comment. Be careful not to change
# the 'exec tail' line above.

Now we take a look at the entry for Windows in grub.cfg.

And paste that right into our 09_custom.

Next, we take a look at the first entry in the linux section of grub.cfg.

and paste that into our 09_custom.

Let's rename the menuentry "Kubuntu".
it's also very important that I changed, in the linux and initrd sections,

and /boot/initrd.img-2.6.31-14-generic

to simply just

and /initrd.img

These always point to the latest version of the files, so it will always boot us to the latest and greatest updated kernel.

If you want a seperator, make a menu entry like "----------Other----------". Be sure to hit enter once or twice after the last menu entry or it wont work and save 09_custom .

Now, open up konsole

And change to the directory with cd /etc/grub.d/ .

If we type ls, we can see that our file isn't green, or executable. This is a requirement, so let's fix this.

Do a sudo chmod +x 09_custom and voila!

Another ls reveals that we've changed the file.
Lastly, we sudo update-grub and it will make our new configurations ready to use.

If we reload grub.cfg, note that it has changed. Make sure to close kate without saving anything to grub.cfg .

We should have shiny new entries in our list. We didn't get rid of the other options, because we want to fall back on them if what we did ever goes wrong. These fallback options look nicer when a proper seperator entry is there.

There you have it! How to fix Grub to that normal people can understand what to do at the boot menu!

No comments: