Thursday, July 17, 2008

Configure Ubuntu GRUB to select the default booting OS

I was frequently annoyed by the fact that the grub start ubuntu by default all the time. As I am still a new-bee in the ubuntu world, I still have to go to windows to do most of my jobs. Thus, I decided to do something to modify the default OS for GRUB. Here is how it is done:

The GRUB menu is controlled by the file called menu.lst.
/boot/grub/menu.lst
Well, run the following command will let you edit this file with root:
sudo nano /boot/grub/menu.lst
You may find an entry like this in the head part of the original file:
# WARNING: If you are using dmraid do not use 'savedefault' or your
# array will desync and will not let you boot your system.
default 0

## timeout sec

Now, check the foot part of this file, you may find a bunch of entires according to the options of your GRUB menu. Mine is like this:
## ## End Default Options ##

title Ubuntu 8.04.1, kernel 2.6.24-19-generic
root (hd0,5)
kernel /boot/vmlinuz-2.6.24-19-generic root=UUID=7f4a3b67-946b-4b1f-88e3-441281d41b04 ro quiet splash
initrd /boot/initrd.img-2.6.24-19-generic
quiet

title Ubuntu 8.04.1, kernel 2.6.24-19-generic (recovery mode)
root (hd0,5)
kernel /boot/vmlinuz-2.6.24-19-generic root=UUID=7f4a3b67-946b-4b1f-88e3-441281d41b04 ro single
initrd /boot/initrd.img-2.6.24-19-generic

title Ubuntu 8.04.1, kernel 2.6.24-16-generic
root (hd0,5)
kernel /boot/vmlinuz-2.6.24-16-generic root=UUID=7f4a3b67-946b-4b1f-88e3-441281d41b04 ro quiet splash
initrd /boot/initrd.img-2.6.24-16-generic
quiet

title Ubuntu 8.04.1, kernel 2.6.24-16-generic (recovery mode)
root (hd0,5)
kernel /boot/vmlinuz-2.6.24-16-generic root=UUID=7f4a3b67-946b-4b1f-88e3-441281d41b04 ro single
initrd /boot/initrd.img-2.6.24-16-generic

title Ubuntu 8.04.1, memtest86+
root (hd0,5)
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/sda1
title Windows Vista SP1
root (hd0,0)
savedefault
makeactive
chainloader +1
Now, as we have 6 entries in our menu list, and the comment shows that the default value starts at 0, you may assume that we should assign the default value to 5, then we can achieve our goal. However, I have made the same mistake as you did. Ridiculously, there is another entry called "Other operating systems:" in the menu list. (Well, now you may point out that it is already showed in the menu.lst file, but the problem is who the hell will assume that as an entry to the menu option?)

Well, anyway, now what you have to do is to assign 6 to the default and everything will be fine. I hope this might be helpful.

No comments: