Tuesday, December 29, 2009

Making Windows the Default Boot with Grub 2

Having installed Ubuntu 9.10 on my mother's computer, I wanted to fix the boot process so that if she didn't do anything, it would boot into Windows as usual.

I went to edit menu.lst, as I have done time out of mind, and it wasn't there.

It turns out that Ubuntu now uses grub2, which has a different way of doing things.

The relevant wiki page is here: http://wiki.ubuntu.com/Grub2

After reading this, I decided to try moving the 'os_prober' that finds the windows partition to have a higher priority:

$ sudo mv 30_os-prober 03_os-prober
$ sudo update-grub

Then I looked at /boot/grub/grub.cfg to see what it had done:

$ vi /boot/grub/grub.cfg

The windows vista loader, which is what I want to be the default, is now the second entry, the first is something called 'Dell Utility Partition'.

Also, the new os_prober entries are now behind the 'debian_theme' entries, which just set colours, and look like they should be at the top. The linux entries are generated with priority 10, so I thought I'd change the os_prober entries to priority 7 to put them between the two:

$ sudo mv 03_os-prober 07_os-prober
$ sudo update-grub

Anyway, at this point, I'm curious, so I reboot.

This has worked fairly well.

The top entry (which is the default), is the 'Dell Utility Partition'. This turns out to run some interesting tests on the hardware, and doesn't seem to do any harm.

Below that, we get Windows Vista, which is ok.

Below that, various Linux kernels. All but the latest should probably be removed.

Below that, memtest86+.

Unfortunately, of course, this isn't a great set up for Mum. Ideally she'd want Windows at the top and the default, and the 'Utility Partition' down with memtest, where she'd never have to worry about it.

Obviously the real solution would be to split the os-prober into two, one which generates the windows entry, and one to find everything else, and to add the two script in with appropriate priorities, but this is a bit too much customization to do on a computer which I'll be 150 miles away from next time it goes wrong.

Fortunately there's an obvious nasty hack, since the detected orders are probably stable, of changing the default boot entry to be entry 1 instead of 0.

Addition and removal of linux kernels shouldn't affect the Utility Partition or the Windows partition, and so entry 1 will always be the desired one. Hopefully.

$ sudo vi /etc/default/grub


$ sudo update-grub

the file /boot/grub/grub.cfg looks good after this,

The spare kernels I can remove with synaptic. Searching for 2.6.31 reveals three files per kernel version, and I just want to remove the old ones, which in this case are: linux-headers-2.6.31-14, linux-headers-2.6.31-14-generic and linux-image-2.6.31-14-generic.

Synaptic seems quite happy with this, and as part of the removal process runs update-grub for me.

Fingers crossed and reboot.
All seems to have worked a treat.

Good luck!

No comments:

Post a Comment