Ubuntu, by default, sets the most recently installed kernel as the default boot option, and then scans the hard disk for other bootable partitions, which it lists in order. Every time a new kernel is installed, the boot order is updated and subsequently for any lasting changes to be made, they need to be added to Ubuntu's grub autoconfiguration.
Ubuntu generates its grub configuration from a series of rules in the /etc/grub.d folder. A default install will have something similar to:
/etc/grub.d$ ls -1The README file in this folder states:
00_header
05_debian_theme
10_linux
20_linux_xen
20_memtest86+
30_os-prober
40_custom
41_custom
README
All executable files in this directory are processed in shell expansion order.Based upon this, I decided to create a file, 07_windows_default and, copying the existing Windows stanza created by the autodetect routine in the existing /boot/grub/grub.cfg (look for the section entitled "### BEGIN /etc/grub.d/30_os-prober ###") with some slight tweaks to the name to make it stand out from the auto options, I ended up with something along the lines of:
00_*: Reserved for 00_header.
10_*: Native boot entries.
20_*: Third party apps (e.g. memtest86+).
The number namespace in-between is configurable by system installer and/or administrator. For example, you can add an entry to boot another OS as 01_otheros, 11_otheros, etc, depending on the position you want it to occupy in the menu; and then adjust the default setting via /etc/default/grub.
I've used Windows 7 here as my home system doesn't have XP but Windows 7 as a dual boot option. The caveat here is that if there are any special shell characters, like $, need to be backslash escaped. I've also removed my XP partition's UUID in the above example - again, I'd recommend people leverage the autodetect routine of Ubuntu and just copy the Windows stanza out of the existing auto-generated config.#!/bin/sh cat <<EOF menuentry "Start Windows 7" --class windows --class os { insmod part_msdos insmod ntfs set root='(/dev/sda,msdos1)' search --no-floppy --fs-uuid --set=root DRIVEUUID chainloader +1 } EOF
Once this file is in place, and has been made executable (Eg. chmod a+x 07_windows_default), running sudo update-grub will trigger Ubuntu to re-run its rules and insert the above Windows stanza above the Ubuntu kernel entries.
Reboot - et voila, Windows is now your default boot option and Ubuntu kernel upgrades won't break it.
No comments:
Post a Comment
Hey... thanks for leaving a comment! Due to Casino spam, I've had to turn on moderation for some of the posts. Apologies - I do read every comment left!