Setting Default Entry in Grub2 and Grub

By Zhiqiang Ma On Apr 23, 2013

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.

By: Zhiqiang Ma Last updated: Apr 23, 2013 Views: 344
Tags: , , , , , ,

About Zhiqiang Ma

Zhiqiang Ma is a PhD candidate at Dep. of CSE, HKUST. He is interested in system software for cloud computing, virtualization of large-scale distributed system, etc. Find Zhiqiang on Facebook, Twitter, LinkedIn and Google+.

2 Comments on Setting Default Entry in Grub2 and Grub | Add Comment
Add your comments, share your thoughts

Be nice. Keep it clean. Stay on topic. No spam.