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. The grubby tool can be used to read information from and make persistent changes to the grub.cfg file. It enables, for example, changing GRUB2 menu entries to specify what arguments to pass to a kernel on system start and changing the default kernel.

List Installed Kernels and Default Kernel

You can use the grubby command to see all kernels installed on an Oracle Linux instance, configuration information about the kernels, which kernel is the default and which kernel is currently running.

  1. From a command line, using administrative privileges connect to the instance using SSH.
  2. List the installed kernels using one of the following options. The list of installed kernels might be different depending on the Oracle Linux version.
    • List the installed kernels in the /boot directory.
      sudo ls -l /boot/vmlinuz*
      -rwxr-xr-x. 1 root root 13701352 Feb 12 19:33 /boot/vmlinuz-0-rescue-7063910fe2979258f8fd66f2fb8b8567
      -rwxr-xr-x. 1 root root 10889384 Feb 11 12:19 /boot/vmlinuz-4.18.0-553.40.1.el8_10.x86_64
      -rwxr-xr-x. 1 root root 13701352 Jan 29 04:13 /boot/vmlinuz-5.15.0-305.176.4.el8uek.x86_64
    • List the kernels using grubby and the --info=ALL command option to see the boot configuration associated with each installed kernel.
      sudo grubby --info=ALL
      index=0 <<Each boot entry is assigned an index, which is a number that indicates its position in the GRUB menu
      kernel="/boot/vmlinuz-5.15.0-305.176.4.el8uek.x86_64" <<Full path to the kernel image
      args="ro crashkernel=auto LANG=en_US.UTF-8 console=tty0 console=ttyS0,115200 rd.luks=0 / <<Command-line arguments passed to the kernel when it boots
            rd.md=0 rd.dm=0 rd.lvm.vg=ocivolume rd.lvm.lv=ocivolume/root rd.net.timeout.carrier=5 /
            netroot=iscsi:169.254.0.2:::1:iqn.2015-02.oracle.boot:uefi /
            rd.iscsi.param=node.session.timeo.replacement_timeout=6000 net.ifnames=1 /
            nvme_core.shutdown_timeout=10 ipmi_si.tryacpi=0 ipmi_si.trydmi=0 libiscsi.debug_libiscsi_eh=1 /   
            loglevel=4 ip=dhcp,dhcp6 rd.net.timeout.dhcp=10 crash_kexec_post_notifiers /
            fips=1 boot=UUID=5097b6ba-ed0e-418a-9c2c-fb25d577991f $tuned_params"
      root="/dev/mapper/ocivolume-root" <<Root partition device
      initrd="/boot/initramfs-5.15.0-305.176.4.el8uek.x86_64.img $tuned_initrd" <<Path to the initial RAM disk (initrd) image
      title="Oracle Linux Server (5.15.0-305.176.4.el8uek.x86_64 with Unbreakable Enterprise Kernel) 8.10" <<Title displayed in the GRUB menu at startup
      id="7063910fe2979258f8fd66f2fb8b8567-5.15.0-305.176.4.el8uek.x86_64" <<Unique identifier for the boot entry
      
      index=1
      kernel="/boot/vmlinuz-4.18.0-553.40.1.el8_10.x86_64"
      ...
      title="Oracle Linux Server (4.18.0-553.40.1.el8_10.x86_64) 8.10"
      ...
      
      index=2
      kernel="/boot/vmlinuz-0-rescue-7063910fe2979258f8fd66f2fb8b8567"
      ...
      title="Oracle Linux Server (0-rescue-7063910fe2979258f8fd66f2fb8b8567 with Unbreakable Enterprise Kernel) 8.10"
      ...

      From the output of sudo grubby --info=ALL, you can determine what you see in the GRUB menu at startup. For example, using the index number and title in the above output, the GRUB menu would look like this:

      Oracle Linux Server (5.15.0-305.176.4.el8uek.x86_64 with Unbreakable Enterprise Kernel) 8.10
      Oracle Linux Server (4.18.0-553.40.1.el8_10.x86_64) 8.10
      Oracle Linux Server (0-rescue-7063910fe2979258f8fd66f2fb8b8567 with Unbreakable Enterprise Kernel) 8.10
  3. List which kernel is already configured as the current default kernel to use at boot and its title and position as seen in the GRUB menu. The default kernel might be different depending on the Oracle Linux version.
    • List default kernel.
      sudo grubby --default-kernel
      /boot/vmlinuz-5.15.0-305.176.4.el8uek.x86_64
      
    • Check the title of the default kernel.
      sudo grubby --default-title

      The output matches the value seen in the GRUB2 menu when starting Oracle Linux

      Oracle Linux Server (5.15.0-305.176.4.el8uek.x86_64 with Unbreakable Enterprise Kernel) 8.10
      
    • Find the position of the default kernel in the kernel boot list.
      sudo grubby --default-index
      0
  4. Check which kernel is currently running on the instance.
    uname -r
    5.15.0-305.176.4.el8uek.x86_64

    If the default kernel and the currently running kernel are not identical, the underlying reasons might be one of the following:

    • You installed a newer kernel, but you have not rebooted the system
    • During a system reboot, you selected an alternative kernel manually to be the operative kernel
    • You manually updated the default kernel but have not rebooted the system after the update

Change Default Kernel

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:

  1. From a command line, using administrative privileges connect to the instance using SSH.
  2. List default kernel.
    sudo grubby --default-kernel
    /boot/vmlinuz-5.15.0-305.176.4.el8uek.x86_64
    
  3. Use the grubby --set-default command to change the default kernel making sure to specify the full path kernel. You can get the kernel path using either of the options in step 2 of Listing Installed Kernels and Default Kernel.
    sudo grubby --set-default /boot/vmlinuz-4.18.0-553.40.1.el8_10.x86_64

    The change takes effect immediately and persists across system reboots.

  4. Verify the default kernel change.
    sudo grubby --default-kernel
    /boot/vmlinuz-4.18.0-553.40.1.el8_10.x86_64
    
  5. (Optional) Set the default kernel to the first position in the kernel boot list using the grubby --set-default-index command.
    sudo grubby --set-default-index=0
    The GRUB menu would now look like:
    Oracle Linux Server (4.18.0-553.40.1.el8_10.x86_64) 8.10
    Oracle Linux Server (5.15.0-305.176.4.el8uek.x86_64 with Unbreakable Enterprise Kernel) 8.10
    Oracle Linux Server (0-rescue-7063910fe2979258f8fd66f2fb8b8567 with Unbreakable Enterprise Kernel) 8.10
  6. Reboot the instance to boot with the new default kernel.

Change Kernel Boot Parameters

You can update the GRUB 2 boot configuration for a specific kernel, or across all kernels that are installed on the Oracle Linux instance.

Use the grubby --update-kernel command to add new arguments, change existing argument values, or remove arguments for a specific kernel or all kernels. Multiple 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.

  1. From a command line, using administrative privileges connect to the instance using SSH.
  2. To update all kernel entries to use a specific kernel boot argument, use grubby --update-kernel=ALL. For example, change the LANG argument:
    sudo grubby --update-kernel=ALL --args LANG=en_GB.UTF-8
  3. Verify the changes have taken effect
    sudo grubby --info=ALL
    index=0
    kernel="/boot/vmlinuz-5.15.0-305.176.4.el8uek.x86_64"
    args="ro crashkernel=auto console=tty0 console=ttyS0,115200 rd.luks=0 rd.md=0 
       rd.dm=0 rd.lvm.vg=ocivolume rd.lvm.lv=ocivolume/root rd.net.timeout.carrier=5 
       netroot=iscsi:169.254.0.2:::1:iqn.2015-02.oracle.boot:uefi 
       rd.iscsi.param=node.session.timeo.replacement_timeout=6000 
       net.ifnames=1 nvme_core.shutdown_timeout=10 ipmi_si.tryacpi=0 ipmi_si.trydmi=0 
       libiscsi.debug_libiscsi_eh=1 loglevel=4 ip=dhcp,dhcp6 rd.net.timeout.dhcp=10   
       crash_kexec_post_notifiers fips=1 boot=UUID=5097b6ba-ed0e-418a-9c2c-fb25d577991f 
       LANG=en_GB.UTF-8 $tuned_params"
    ...
    index=1
    kernel="/boot/vmlinuz-4.18.0-553.40.1.el8_10.x86_64"
    args="ro crashkernel=auto console=tty0 console=ttyS0,115200 rd.luks=0 rd.md=0 
       rd.dm=0 rd.lvm.vg=ocivolume rd.lvm.lv=ocivolume/root rd.net.timeout.carrier=5 
       netroot=iscsi:169.254.0.2:::1:iqn.2015-02.oracle.boot:uefi 
       rd.iscsi.param=node.session.timeo.replacement_timeout=6000 net.ifnames=1 
       nvme_core.shutdown_timeout=10 ipmi_si.tryacpi=0 ipmi_si.trydmi=0 libiscsi.debug_libiscsi_eh=1 
       loglevel=4 ip=dhcp,dhcp6 rd.net.timeout.dhcp=10 crash_kexec_post_notifiers 
       fips=1 boot=UUID=5097b6ba-ed0e-418a-9c2c-fb25d577991f 
       LANG=en_GB.UTF-8 $tuned_params"
    ...
    index=2
    kernel="/boot/vmlinuz-0-rescue-7063910fe2979258f8fd66f2fb8b8567"
    args="ro crashkernel=auto console=tty0 console=ttyS0,115200 rd.luks=0 rd.md=0 
       rd.dm=0 rd.lvm.vg=ocivolume rd.lvm.lv=ocivolume/root rd.net.timeout.carrier=5 
       netroot=iscsi:169.254.0.2:::1:iqn.2015-02.oracle.boot:uefi  
       rd.iscsi.param=node.session.timeo.replacement_timeout=6000 net.ifnames=1 
       nvme_core.shutdown_timeout=10 ipmi_si.tryacpi=0 ipmi_si.trydmi=0 
       libiscsi.debug_libiscsi_eh=1 loglevel=4 ip=dhcp,dhcp6 rd.net.timeout.dhcp=10   
       crash_kexec_post_notifiers fips=1 boot=UUID=5097b6ba-ed0e-418a-9c2c-fb25d577991f 
       LANG=en_GB.UTF-8 $tuned_params"
    ...
  4. Reboot the instance to boot with the new kernel configuration.