Using grubby to Manage Kernels

Use the grubby command to manage the GRUB 2 configuration on the system, including selecting the default boot kernel or configuring extra kernel command line boot parameters to be used at boot.

See the grubby(8) manual page for more information.

Checking Available Kernels on the System

Kernels are named to include the upstream version number, the distribution build, and the kernel family.

See About Linux Kernels for extra context.

Several methods are available for checking which kernels are available on a system:

  1. List the kernels in the /boot directory.
    ls -1 /boot/vmlinuz*

    The command produces an exact list of kernels available on the system.

  2. Use the grubby command on specific kernels or using the ALL option.
    sudo grubby --info /boot/vmlinuz-kernel-version.kernel_suffix*
    sudo grubby --info ALL

    The command provides fuller information about the boot configuration associated with each kernel in the system's /boot directory. The details are based on the GRUB title configuration.

Comparing the Default Kernel to the Running Kernel

The running kernel and the kernel configured as the default kernel that GRUB 2 selects to boot into after a timeout period for the boot menu can differ.

If the default kernel version and the running kernel version aren't identical, the underlying reasons might be one of the following:

  • A newer kernel is installed, but the system hasn't been rebooted.

  • During a system reboot, a different kernel was manually selected to be the operative kernel.

  • The default kernel was manually updated but the system hasn't been rebooted after the update.

To compare the default configured kernel to the running kernel, do the following:
  1. Check the default kernel configured in GRUB 2.

    To check which kernel is already configured as the current default kernel to use at boot, run:

    sudo grubby --default-kernel
  2. Check the running kernel version.

    To check which kernel is running on a system, run:

    uname -r

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, do either of the following:

  1. 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-kernel-version.kernel-suffix.arch

    Replace kernel-version and kernel_suffix with the values that match the target kernel. For example, run:

    sudo grubby --set-default /boot/vmlinuz-6.12.0-100.28.2.el10uek.x86_64

    The change takes effect immediately and persists across system reboots.

  2. 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

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.

Changing Kernel Command Line Boot Parameters

Sometimes you might need to edit the GRUB 2 configuration to specify particular kernel boot parameters on the kernel command line. Setting parameters in the GRUB 2 configuration means that the parameters are used for the affected kernels at every boot.

You can update the GRUB 2 boot configuration for a specific kernel, or across all kernels that are installed on the system by doing the following:

  1. Use the grubby --update-kernel command to update a kernel entry with --args to add new arguments or to change existing argument values, or --remove-args to remove existing arguments.

    Several arguments can be specified for each option in a quoted space-separated list. You can add and remove arguments in the same operation. When using the --args option, if an argument already exists the new value replaces the old values.

    To update a specific kernel, run the grubby --update-kernel command with the full path to the kernel that you want to update. To update all kernel entries to use a specific kernel boot argument, you can use grubby --update-kernel=ALL.

    For example, you can update all kernel entries to change the loglevel and LANG arguments:

    sudo grubby --update-kernel=ALL --args "loglevel=3,LANG=en_GB.UTF-8"

    See Kernel Boot Parameter Reference for more information about kernel parameters.

  2. Verify that the changes have taken effect and that the command line arguments are correct for the kernel that you updated.

    For example, if you have made a change to all kernels, use the grubby --info ALL command to check that the change is implemented across all kernels:

    sudo grubby --info ALL

Checking the Kernel Command Line Last Used to Boot The System

The kernel boot parameters that were last used to boot a system are recorded in /proc/cmdline.

For more information, see the kernel-command-line(7) manual page.

Check the contents of /proc/cmdline to view the kernel command line that was used to boot the running system.
cat /proc/cmdline
BOOT_IMAGE=(hd0,gpt2)/vmlinuz-5.15.0-208.159.3.2.el9uek.x86_64 
root=UUID=72dfa724-5feb-49e2-8869-40625bfebb01 ro 
resume=UUID=13078314-ebff-4c44-b18c-3445f6802198 
rd.luks.uuid=luks-a80f8f10-75b6-45de-b63e-64b8b6a3a94b 
rhgb quiet crashkernel=1G-64G:448M,64G-:512M