Change default boot kernel in Linux Grub2

Grub2 : change Linux default boot kernel

When you have to change the default boot kernel of Linux which uses Grub2, instead of going through the /etc/grub2.cfg  file, here is a quick and easy tip on how to identify the kernels and set the boot kernel.

This command lists all the kernel versions installed on your machine. Note that the position of a menu entry in the list is denoted by a number starting with zero.

[[email protected] ~]# grep ^menuentry /boot/grub2/grub.cfg | cut -f 2 -d ‘ | nl -v 0      0  CentOS Linux (3.10.0-229.7.2.el7.x86_64) 7 (Core)      1  CentOS Linux (3.10.0-229.7.2.el7.x86_64) 7 (Core) with debugging 2  CentOS Linux (3.10.0-229.4.2.el7.x86_64) 7 (Core)      3  CentOS Linux (3.10.0-229.4.2.el7.x86_64) 7 (Core) with debugging      4  CentOS Linux (3.10.0-229.1.2.el7.x86_64) 7 (Core)      5  CentOS Linux (3.10.0-229.1.2.el7.x86_64) 7 (Core) with debugging      6  CentOS Linux 7 (Core), with Linux 3.10.0-229.el7.x86_64      7  CentOS Linux 7 (Core), with Linux 0-rescue-7d6bf4398fe54f89842fd24c897255d9 [[email protected] ~]#

12345678910[[email protected] ~]# grep ^menuentry /boot/grub2/grub.cfg | cut -f 2 -d ‘ | nl -v 0     0  CentOS Linux (3.10.0-229.7.2.el7.x86_64) 7 (Core)     1  CentOS Linux (3.10.0-229.7.2.el7.x86_64) 7 (Core) with debugging     2  CentOS Linux (3.10.0-229.4.2.el7.x86_64) 7 (Core)     3  CentOS Linux (3.10.0-229.4.2.el7.x86_64) 7 (Core) with debugging     4  CentOS Linux (3.10.0-229.1.2.el7.x86_64) 7 (Core)     5  CentOS Linux (3.10.0-229.1.2.el7.x86_64) 7 (Core) with debugging     6  CentOS Linux 7 (Core), with Linux 3.10.0-229.el7.x86_64     7  CentOS Linux 7 (Core), with Linux 0-rescue-7d6bf4398fe54f89842fd24c897255d9[[email protected] ~]#

Change the kernel version by issuing the grub2-set-default command. This sets default boot kernel in grub2.cfg as default run. Changing the kernel version requires a reboot.

grub2-set-default 2

1grub2-set-default 2

The value number “2” passed as an argument to this command selects the kernel 2 listed above.

Total
0
Shares
Leave a Reply

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

Previous Post

Netapp Storage Administration articles

Next Post

GeoIP Based Country Blocking for Apache

Related Posts