How to change the Grub2 boot order?

How can I change the boot order in grub2? Here is a step by step guide,

In a terminal type,

# grep menuentry /boot/grub2/grub.cfg
menuentry 'CentOS Linux (4.6.4-1.el7.elrepo.x86_64) 7 (Core) with debugging' --class rhel fedora --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-3.10.0-229.el7.x86_64-advanced-169f51f6-092c-43b8-bea9-bdc484dc66c6' {


menuentry 'CentOS Linux (4.6.4-1.el7.elrepo.x86_64) 7 (Core)' --class rhel fedora --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-3.10.0-229.el7.x86_64-advanced-169f51f6-092c-43b8-bea9-bdc484dc66c6' {
menuentry 'CentOS Linux (3.10.0-327.28.3.el7.x86_64) 7 (Core) with debugging' --class rhel fedora --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-3.10.0-229.el7.x86_64-advanced-169f51f6-092c-43b8-bea9-bdc484dc66c6' {

This will display all your grub entries. Highlight the entry you want to default to – for example ‘CentOS Linux (4.6.4-1.el7.elrepo.x86_64) 7 (Core)’,

Type

# vim /etc/default/grub

Change the entry

GRUB_DEFAULT=0

to

GRUB_DEFAULT='CentOS Linux (4.6.4-1.el7.elrepo.x86_64) 7 (Core)'

i.e. paste the entry you want (including the quotes)
Save, then type

# grub2-mkconfig -o /boot/grub2/grub.cfg

Alternatively, you can run this single command instead,

# grub2-set-default 'CentOS Linux (4.6.4-1.el7.elrepo.x86_64) 7 (Core)'

The reboot your system to make the change take effect.

Share Button

Leave a comment

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