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.

[root@centos01 ~]# 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 [root@centos01 ~]#

12345678910[root@centos01 ~]# 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[root@centos01 ~]#

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.

0 Shares:
Leave a Reply

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

You May Also Like
Read More

Sticky bit

What is the “sticky bit”? (t and T) The sticky bit is primarily used on shared directories.  It…
Read More

Loadbalancer

A good presentation from F5 explaining all features of Loadbalancer :  http://www.f5.com/flash/product-demo/
Read More

Netapp Snapvault guide

Netapp SnapVault is a heterogeneous disk-to-disk backup solution for Netapp filers and heterogeneous OS systems (Windows, Linux ,…