Skip to content

Instantly share code, notes, and snippets.

@kurtis318
Created October 11, 2019 19:08
Show Gist options
  • Save kurtis318/77188a196e1351e0c8fc169fe5172219 to your computer and use it in GitHub Desktop.
Save kurtis318/77188a196e1351e0c8fc169fe5172219 to your computer and use it in GitHub Desktop.
How to boot specific kernel in RHEL

Issue:

There are times when a newly installed kernel has boot or runtime problems. I need a way to boot a specific kernel automatically.

Solution:

REF: https://access.redhat.com/solutions/1605183

$ cat /etc/sysconfig/kernel
# UPDATEDEFAULT specifies if new-kernel-pkg should make
# new kernels the default
UPDATEDEFAULT=yes

# DEFAULTKERNEL specifies the default kernel package type
DEFAULTKERNEL=kernel
~]# awk -F\' '$1=="menuentry " {print $2}' /etc/grub2.cfg

Eg: 
~]#  awk -F\' '$1=="menuentry " {print $2}' /etc/grub2-efi.cfg 
Red Hat Enterprise Linux Server (3.10.0-693.el7.x86_64) 7.3 (Maipo)           <<==== Entry 0
Red Hat Enterprise Linux Server (3.10.0-514.el7.x86_64) 7.3 (Maipo)           <<==== Entry  1
Red Hat Enterprise Linux Server (0-rescue-d3c598b9d2204138bd2e1001316a5cc6) 7.3 (Maipo)
~]# grub2-set-default 1

~]# cat /boot/grub2/grubenv |grep saved

Eg:
~]# cat /boot/grub2/grubenv |grep saved
saved_entry=1

Rebuild the /boot/grub2/grub.cfg file by running the grub2-mkconfig -o command as follows:

On BIOS-based machines: ~]# grub2-mkconfig -o /boot/grub2/grub.cfg
On UEFI-based machines: ~]# grub2-mkconfig -o /boot/efi/EFI/redhat/grub.cfg
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment