Changing Default Boot Order In Grub2

If you dual boot a system, usually windows is the first and linux is the last installed. Linux by default will install Grub2 boot loader and will pick the linux installation to boot by default. If you are primarily a windows user and would prefer to boot to windows normally follow the below instructions.

Normally you would just select the boot order number and that would normally work fine, however if you install another kernel or upgrade your system you might have multiple entries in the grub boot menu and thus your default boot number will change. We will now configure the boot loader to pick via name instead of boot number.

Find out all boot menu items you have via: fgrep menuentry /boot/grub/grub.cfg

you might get the following as a result:
menuentry “Ubuntu, Linux 2.6.31-15-generic” {
menuentry “Ubuntu, Linux 2.6.31-15-generic (recovery mode)” {
menuentry “Ubuntu, Linux 2.6.31-14-generic” {
menuentry “Ubuntu, Linux 2.6.31-14-generic (recovery mode)” {
menuentry “Memory test (memtest86+)” {
menuentry “Memory test (memtest86+, serial console 115200)” {
menuentry “Windows Vista (loader) (on /dev/sda1)” {

Mark and copy the entry you want to stay bootable, including double quotes, for example "Windows Vista (loader) (on /dev/sda1)"

Now we edit the boot loader config file. gksudo gedit /etc/default/grub, look for the line that says "GRUB_DEFAULT=" and change it to GRUB_DEFAULT=”Windows Vista (loader) (on /dev/sda1)”, save and exit.

Now to comit those changes to the boot loader we run sudo update-grub

From Now on it no matter what numbered entry it is on the list it will pick the name to default boot into and not the numbered entry

You can do the same with linux and boot to a specific kernel all the time, just follow the same steps and replace the GRUB_DEFAULT= entry with whatever menu item you wish, which is great for custom kernels.