CentOS/RHEL 7 - Server does not boot after modifying the default kernel entry in GRUB

The problem

We have changed the default kernel entry to boot from in GRUB using the “grub2-set-default” command. But after taking the reboot of the server, it gets stuck at the GRUB menu. console shows the GRUB menu but does not move to the next step.

Use the ^ and v keys to change the selection.
Press 'e' to edit the selected item, or 'c' for a command prompt.
RedHat Linux Server (4.14.35-1902.6.6.el7uek.x86_64 with Unbreakable
RedHat Linux Server (3.10.0-1062.1.2.el7.x86_64 with Linux) 7.7
RedHat Linux Server (3.10.0-957.10.1.el7.x86_64 with Linux) 7.7
RedHat Linux Server (3.10.0-693.17.1.0.1.el7.x86_64 with Linux) 7.7
RedHat Linux Server (0-rescue-8a5a65691bad4095975d0099d3184364 with Linux

This is a XEN virtual server.

The Solution

The initramfs and modules.dep.bin has been modified from the original rpms.

# rpm -q -V kernel-uek-4.14.35-1844.3.2.el7uek.x86_64
.M....... g /boot/initramfs-4.14.35-1844.3.2.el7uek.x86_64.img
..5....T. /etc/ld.so.conf.d/kernel-4.14.35-1844.3.2.el7uek.x86_64.conf
.......T. /lib/modules/4.14.35-1844.3.2.el7uek.x86_64/modules.alias.bin
.......T. /lib/modules/4.14.35-1844.3.2.el7uek.x86_64/modules.builtin.bin
S.5....T. /lib/modules/4.14.35-1844.3.2.el7uek.x86_64/modules.dep.bin

Follow the steps outlined below to resolve the above issue:

1. Remove the following GRUB_CMDLINE_LINUX options from /etc/default/grub file:

xen-blkfront.max_ring_page_order=4 xen-blkfront.max=8

2. Update the RHCK kernel:

# yum update kernel.x86_64

3. Update the GRUB2 cfg file:

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

4. Check the kernel options as shown below using awk:

# awk -F\' '$1=="menuentry " {print i++ " : " $2}' /etc/grub2.cfg
0:Oracle Linux Server (4.14.35-1844.3.2.el7uek.x86_64 with Unbreakable Enterprise Kernel) 7.6
1:Oracle Linux Server (4.1.12-112.14.13.el7uek.x86_64 with Unbreakable Enterprise Kernel) 7.6
2:Oracle Linux Server (3.10.0-1062.4.1.el7.x86_64 with Linux) 7.6
3:Oracle Linux Server (3.10.0-957.10.1.el7.x86_64 with Linux) 7.6
4:Oracle Linux Server (3.10.0-693.17.1.0.1.el7.x86_64 with Linux) 7.6
5:Oracle Linux Server (0-rescue-8a5a65691bad4095975d0099d3184364 with Linux) 7.6Set the default kernel to RHCK (e.g. 3.10.0-514.10.2.el7.x86_64), which should be entry #0

5. Set the default kernel using the “grub2-set-default” command:

# grub2-set-default 2

6. Update the GRUB2 cfg file:

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

7. Add the Xen drivers:

# dracut -f -v --add-drivers "xen-blkfront xen-netfront"

8. Reboot the instance from the XEN web GUI interface.