Using grubby to Manage Kernels
The grubby tool can be used to read information from and make persistent changes to the grub.cfg
file which defines the GRUB configuration for an Oracle Linux instance. Using the grubby
command, you can view kernel configuration, specify the default boot kernel, configure extra kernel command line boot parameters, and change the kernel boot (GRUB) menu. See the grubby(8)
manual page for more information.
List Installed Kernels and Default Kernel
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 active.
- From a command line, using administrative privileges connect to the instance using SSH.
- 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 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-6.12.0-102.36.5.2.el10uek.x86_64" <--Full path to the kernel image args="ro $tuned_params 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.dhcp=10 rd.net.timeout.carrier=5 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 crash_kexec_post_notifiers crashkernel=1G-64G:448M,64G-:512M netroot=iscsi rd.iscsi.firmware=1" root="/dev/mapper/ocivolume-root" <--Root partition device initrd="/boot/initramfs-6.12.0-102.36.5.2.el10uek.x86_64.img $tuned_initrd" <--Path to the initial RAM disk (initrd) image title="Oracle Linux Server (6.12.0-102.36.5.2.el10uek.x86_64 with Unbreakable Enterprise Kernel) 10.0" <--Title displayed in the GRUB menu at startup id="3d18a447860027858b15c8276ccc1ab3-6.12.0-102.36.5.2.el10uek.x86_64" <--Unique identifier for the boot entry index=1 kernel="/boot/vmlinuz-6.12.0-55.27.1.0.1.el10_0.x86_64" ... title="Oracle Linux Server (6.12.0-55.27.1.0.1.el10_0.x86_64) 10.0" ... index=2 kernel="/boot/vmlinuz-0-rescue-3d18a447860027858b15c8276ccc1ab3" ... title="Oracle Linux Server (0-rescue-3d18a447860027858b15c8276ccc1ab3 with Unbreakable Enterprise Kernel) 10.0" ...
The output of
sudo grubby --info=ALL
predicts what displays in the kernel boot menu at startup. For example, using the index numbers and titles in the preceding output, the kernel boot menu would show the following:Oracle Linux Server (6.12.0-102.36.5.2.el10uek.x86_64 with Unbreakable Enterprise Kernel) 10.0 Oracle Linux Server (6.12.0-55.27.1.0.1.el10_0.x86_64) 10.0 Oracle Linux Server (0-rescue-3d18a447860027858b15c8276ccc1ab3 with Unbreakable Enterprise Kernel) 10.0
- List the installed kernels in the
/boot
directory.sudo ls -l /boot/vmlinuz*
-rwxr-xr-x. 1 root root 17048272 Aug 19 20:35 /boot/vmlinuz-0-rescue-3d18a447860027858b15c8276ccc1ab3 -rwxr-xr-x. 1 root root 17048272 Aug 13 00:00 /boot/vmlinuz-6.12.0-102.36.5.2.el10uek.x86_64 -rwxr-xr-x. 1 root root 15852240 Aug 14 00:00 /boot/vmlinuz-6.12.0-55.27.1.0.1.el10_0.x86_64
- List the kernels using
- Show which kernel is configured as the default kernel to use at boot and its title and position in the kernel boot menu. The default kernel depends on the Oracle Linux version.
- Show the default kernel.
sudo grubby --default-kernel
/boot/vmlinuz-6.12.0-102.36.5.2.el10uek.x86_64
- Show the default kernel's title.
sudo grubby --default-title
The output matches the value seen in the kernel boot menu when the Oracle Linux instance starts.
Oracle Linux Server (6.12.0-102.36.5.2.el10uek.x86_64 with Unbreakable Enterprise Kernel) 10.0
- Show the index position of the default kernel in the kernel boot list.
sudo grubby --default-index
0
- Show the default kernel.
- Check which kernel is running on the instance.
uname -r
6.12.0-102.36.5.2.el10uek.x86_64
The default kernel and the running kernel might not be identical because:
- You installed a newer kernel, but you haven't rebooted the system.
- During a system reboot, you manually selected another kernel to be the active kernel.
- You manually updated the default kernel but haven't yet rebooted the system.
Change Default Kernel
Use the grubby
command to set the default boot kernel in the GRUB 2 configuration.
- From a command line, using administrative privileges connect to the instance using SSH.
- Show the default kernel.
sudo grubby --default-kernel
For example:
/boot/vmlinuz-6.12.0-102.36.5.2.el10uek.x86_64
- Use the
grubby --set-default
command to change the default kernel making sure to specify the full path to the kernel. You can get the kernel path using either of the options in step 2 of Listing Installed Kernels and Default Kernel.For example:
sudo grubby --set-default /boot/vmlinuz-6.12.0-55.27.1.0.1.el10_0.x86_64
The change takes effect immediately and persists across system reboots.
- Verify the default kernel change.
sudo grubby --default-kernel
For example:
/boot/vmlinuz-6.12.0-55.27.1.0.1.el10_0.x86_64
- (Optional) Set the new default kernel to the first position in the kernel boot menu using the
grubby --set-default-index
command.The new default kernel is displayed first in the kernel boot menu, for example:sudo grubby --set-default-index=0
Oracle Linux Server (6.12.0-55.27.1.0.1.el10_0.x86_64) 10.0 Oracle Linux Server (6.12.0-102.36.5.2.el10uek.x86_64 with Unbreakable Enterprise Kernel) 10.0 Oracle Linux Server (0-rescue-3d18a447860027858b15c8276ccc1ab3 with Unbreakable Enterprise Kernel) 10.0
- Reboot the instance to boot with the new default kernel.
Change Kernel Boot Parameters
Use the grubby --update-kernel
command to add new arguments, change existing argument values, or remove arguments for a specific kernel or all kernels. Several arguments can be specified for each option in a quoted list with each argument separated by spaces. 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.
- From a command line, using administrative privileges connect to the instance using SSH.
- Use the
grubby --update-kernel
command to change or add a specific kernel boot argument. For example, update the kernel parameters to change the LANG argument for:- all kernels
sudo grubby --update-kernel=ALL --args LANG=en_GB.UTF-8
- one kernel
sudo grubby --update-kernel /boot/vmlinuz-6.12.0-102.36.5.2.el10uek.x86_64 --args LANG=en_GB.UTF-8
- all kernels
- Verify the changes have taken effect.
sudo grubby --info=ALL
- all kernels
index=0 kernel="/boot/vmlinuz-6.12.0-102.36.5.2.el10uek.x86_64" args="ro $tuned_params 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.dhcp=10 rd.net.timeout.carrier=5 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 crash_kexec_post_notifiers crashkernel=1G-64G:448M,64G-:512M netroot=iscsi rd.iscsi.firmware=1 LANG=en_GB.UTF-8" ... index=1 kernel="/boot/vmlinuz-6.12.0-55.27.1.0.1.el10_0.x86_64" args="ro $tuned_params 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.dhcp=10 rd.net.timeout.carrier=5 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 crash_kexec_post_notifiers crashkernel=1G-64G:448M,64G-:512M netroot=iscsi rd.iscsi.firmware=1 LANG=en_GB.UTF-8" ...
- one kernel
index=0 kernel="/boot/vmlinuz-6.12.0-102.36.5.2.el10uek.x86_64" args="ro $tuned_params 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.dhcp=10 rd.net.timeout.carrier=5 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 crash_kexec_post_notifiers crashkernel=1G-64G:448M,64G-:512M netroot=iscsi rd.iscsi.firmware=1 LANG=en_GB.UTF-8" ... index=1 kernel="/boot/vmlinuz-6.12.0-55.27.1.0.1.el10_0.x86_64" args="ro $tuned_params LANG=en_US.UTF-8 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.dhcp=10 rd.net.timeout.carrier=5 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 crash_kexec_post_notifiers crashkernel=1G-64G:448M,64G-:512M netroot=iscsi rd.iscsi.firmware=1" ...
- all kernels
- Reboot the instance to boot with the new kernel configuration.
To change kernel boot parameters without grubby, edit the
/etc/default/grub
file directly and modify boot parameter settings in the GRUB_CMDLINE_LINUX
definition. For example, change LANG=en_US.UTF-8
to LANG=en_GB.UTF-8
:GRUB_CMDLINE_LINUX="crashkernel=auto LANG=en_GB.UTF-8 console=tty0 console=ttyS0
,115200 rd.luks=0 rd.md=0 rd.dm=0 rd.lvm.vg=ocivolume rd.lvm.lv=ocivolume/root r
d.net.timeout.carrier=5 netroot=iscsi:169.254.0.2:::1:iqn.2015-02.oracle.boot:ue
fi 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_libi
scsi_eh=1 loglevel=4 ip=dhcp,dhcp6 rd.net.timeout.dhcp=10 crash_kexec_post_notif
iers"
For the changes to take effect at the next system reboot, rebuild the GRUB 2 configuration: sudo grub2-mkconfig -o /boot/grub2/grub.cfg