Setting Default Entry in Grub2 and Grub
Linux booting is usually controlled by Grub or the new Grub2. Setting the default booting entry is a frequent operations. Here, we introduce how to set the default entry in Grub2 and Grub.
Setting the default booting entry in grub2
Fist, list all the entries in the grub.cfg by:
# grep menuentry /boot/grub2/grub.cfg | cut -d "'" -f2
Second the default entry by the entry’s name.
For example, the command to set the default entry to be ‘Fedora, with Xen hypervisor’ is as follows.
# grub2-set-default 'Fedora, with Xen hypervisor'
Last, verify the default entry what we just set.
# grub2-editenv list
This should print out what we set.
Bonus: we may also want to change the boot option which is stored in ‘/etc/sysconfig/grub’. After editing the file, we can generate the new configuration file for grub2 as follows.
# grub2-mkconfig -o /boot/grub2/grub.cfg
Setting the default booting entry in grub
In grub (before version 2, actually it is usually version 0.99), the default entry is stored in /boot/grub/grub.conf. The default entry to boot is specified by the ‘default’ variable such as
default=2
The ’2′ here is to set the default entry to be the 2nd (start from 0) one.
Tags: Command line, Fedora, Grub, Grub2, Server config, shell, Tutorial
To select a submenu in a menu, e.g. “Fedora, with Linux 3.8.3-103.fc17.x86_64″ under “Advanced options for Fedora”:
# grub2-set-default ‘Advanced options for Fedora>Fedora, with Linux 3.8.3-103.fc17.x86_64′
Note the ‘>’.