Grub linux default menu option

Jump to navigation Jump to search

The (odd) proper way to change grubs default menu entry

This example is using grub2 (1.99-21ubuntu3.1) in Ubuntu 12.04 with kernel 3.2.0-29-generic

  • Change GRUB_DEFAULT=0 to GRUB_DEFAULT=saved in /etc/default/grub
  • Update config generating new grub.cfg with (easiest) update-grub (or 'grub-mkconfig -o /boot/grub/grub.cfg')
$ sudo nano -w /etc/default/grub
$ sudo update-grub

Check it correctly set, should now have default="${saved_entry}" instead of default="0"

$ grep "def" /boot/grub/grub.cfg
# from /etc/grub.d and settings from /etc/default/grub
set default="${saved_entry}"
function savedefault {

Check out what menu options are

$ grep ^menuentry /boot/grub/grub.cfg | cut -d "'" -f2
Ubuntu, with Linux 3.2.0-29-generic
Ubuntu, with Linux 3.2.0-29-generic (recovery mode)
Ubuntu, with Linux 3.0.0-24-generic
Ubuntu, with Linux 3.0.0-24-generic (recovery mode)
Ubuntu, with Linux 2.6.38-10-generic
Ubuntu, with Linux 2.6.38-10-generic (recovery mode)
menuentry "Memory test (memtest86+)" {
menuentry "Memory test (memtest86+, serial console 115200)" {
menuentry "Microsoft Windows XP Professional (on /dev/sda1)" --class windows --class os {
menuentry "Windows 7 (loader) (on /dev/sda2)" --class windows --class os {
  • Assuming that you want to set Win7 to default (not recommended!), take the menuentry title from above list (quoted bit).
  • Check it is set to what you had in mind with grub-editenv.
  • Note, If set default="${saved_entry}" is NOT set above, it ill still default to 0 not what grub-editenv list says.
$ sudo grub-set-default "Windows 7 (loader) (on /dev/sda2)"
$ grub-editenv list
saved_entry=Windows 7 (loader) (on /dev/sda2)

Or to a specific Ubuntu kernel version

$ sudo grub-set-default "Ubuntu, with Linux 3.0.0-24-generic"
$ grub-editenv list
saved_entry=Ubuntu, with Linux 3.0.0-24-generic


Stop Grub adding other O/S's

To stop grub adding Windows 7 etc. to the boot menu, add




and re-run

supo update-grub