Changing the default boot item in Grub2

Grub

It used to be easy to manage grub. Simple changes to /boot/grub/menu.lst you were a-for-away. If you run a dual-boot environment (e.g, Ubuntu and Windows) and you want to change your Grub config to boot to a specific OS these days however (with the advent of newer versions of Grub) there are different steps to follow.

In this example, I’m running Windows 7 and Ubuntu 14.04 on the same machine in a dual-boot configuration. I need Windows to be the default menu entry.

Step 1: Find the menuentry for the operating system you want to make the default boot option

hendri@mercury:~$ grep 'menuentry ' /boot/grub/grub.cfg
 
menuentry 'Ubuntu' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-simple-531984cc-cdb4-4d22-9e98-2914966fd84e' {
        menuentry 'Ubuntu, with Linux 3.16.0-30-generic' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-3.16.0-30-generic-advanced-531984cc-cdb4-4d22-9e98-2914966fd84e' {
        menuentry 'Ubuntu, with Linux 3.16.0-30-generic (recovery mode)' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-3.16.0-30-generic-recovery-531984cc-cdb4-4d22-9e98-2914966fd84e' {
menuentry 'Memory test (memtest86+)' {
menuentry 'Memory test (memtest86+, serial console 115200)' {
menuentry 'Windows 7 (loader) (on /dev/sda1)' --class windows --class os $menuentry_id_option 'osprober-chain-A4AE5922AE58EE74' {
    menuentry "Memory Tester (memtest86+)" --class memtest86 --class gnu --class tool {

In the above output, copy/record the Windows 7 (loader) (on /dev/sda1) text.

Step 2: Edit /etc/default/grub using your preferred editor and make GRUB_DEFAULT the text above

GRUB_DEFAULT="Windows 7 (loader) (on /dev/sda1)"
 
#save and exit

Step 3: Update grub

hendri@mercury:~$ sudo update-grub

That’s it. You should now have your Windows host boot by default

Leave a Reply

Your email address will not be published. Required fields are marked *