Default Boot Specification with GRUB 2 (Ubuntu 9.10)

I got some good news in a comment over on a few days ago.

I got some good news in a comment over on a few days ago. The problem I was looking at was setting the default boot selection on Ubuntu 9.10, or more generally with GRUB 2. The difficulty is that GRUB 2 regenerates its grub.cfg file, and during that generation it looks for additional Linux kernels in /boot and automatically includes any that it finds there. This means that when it is first installed, there are two "native" boot entries, one for a normal boot and one for a recovery boot. Additional boot options follow these two. So, for example on Ubuntu 9.10, if you want to boot Windows by default (ugh), the default would be option 4 (two for Linux and two for memtest86+, then Windows).

Unfortunately, when updates are installed and the kernel version is incremented, GRUB 2 finds another bootable kernel image, and adds it to the grub.cfg file, so now you have two for the new image, two for the old image, two for memtest86+, and uh-oh, your Windows boot has suddenly become option 6 rather than 4, and your default boot of option 4 gets you memtest86+. Probably not what you want.

What I just learned is that GRUB 2 will take not only numbers for the default boot, it will also take the "menu text" for the options. The only thing you have to be careful of is that it must be the complete text exactly as it appears in the menu. So if I want my S6510 to boot WinXP, I can set the boot default like this:

GRUB_DEFAULT="Microsoft Windows XP Professional (on /dev/sda1)"

This definition goes in the file /etc/default/grub, so that it will be preserved when GRUB regenerates its config file. Your exact text will vary, depending on what version of Windows you have, and where it is installed, of course. You can copy it out of grub.cfg the first time, to be sure you have it exactly right.

jw 19/11/2009