Changing the Default Kernel

Use grubby to set the default kernel that GRUB2 boots into after a timeout period is reached when displaying the GRUB2 boot menu.

You might change the default kernel from RHCK to UEK, from UEK to RHCK, or to switch to a specific kernel version.

You can follow one of two options to set the default kernel in GRUB 2, by using the grubby command, choose either of the following:

  • Use the grubby --set-default command to set the default kernel.

    To switch to a different default kernel, run the following command making sure to specify the full path to the selected default kernel:

    sudo grubby --set-default /boot/vmlinuz-5.15.0-208.159.3.2.el9uek.x86_64

    The change takes effect immediately and persists across system reboots.

  • Use the grubby --set-default-index command to set the default kernel to match the kernel at a particular index point in the kernel boot list. The index values are displayed when you run the grubby --info command

    For example, you can use the --set-default-index=0 option to set the default kernel to the first kernel listed in the kernel boot index by running:

    sudo grubby --set-default-index=0

Example 5-1 Switch to the Most Recent Available RHCK or UEK Kernel

By using the naming convention to identify UEK kernels and RHCK kernels that are available in the /boot directory, you can easily switch the default kernel to use the most recent version of either kernel type.

  • To switch to the most recent version of UEK on the system, run:
    sudo grubby --set-default $(ls /boot/vmlinuz-* | grep 'uek' | sort -V | tail -1)
  • To switch to the most recent version of RHCK on the system, run:
    sudo grubby --set-default $(ls /boot/vmlinuz-* | grep -v 'uek' | sort -V | tail -1)

Reboot the system after setting the default kernel to switch to that kernel type.