Edit kernel boot options with grubby

Grubby is a useful tool to change boot options on RHEL-based systems with grub2 since it is not preferable to manually edit config files for grub2 in RHEL8/9.

Messing with default kernel

To list all kernel menu entries, enter:

grubby --info=ALL
index=0
kernel="/boot/vmlinuz-4.18.0-372.9.1.el8.x86_64"
args="ro crashkernel=auto resume=/dev/mapper/rhel-swap rd.lvm.lv=rhel/root rd.lvm.lv=rhel/swap rhgb quiet $tuned_params zswap.enabled=1"
root="/dev/mapper/rhel-root"
initrd="/boot/initramfs-4.18.0-372.9.1.el8.x86_64.img $tuned_initrd"
title="Red Hat Enterprise Linux (4.18.0-372.9.1.el8.x86_64) 8.6 (Ootpa)"
id="67db13ba8cdb420794ef3ee0a8313205-4.18.0-372.9.1.el8.x86_64"
index=1
kernel="/boot/vmlinuz-0-rescue-67db13ba8cdb420794ef3ee0a8313205"
args="ro crashkernel=auto resume=/dev/mapper/rhel-swap rd.lvm.lv=rhel/root rd.lvm.lv=rhel/swap rhgb quiet"
root="/dev/mapper/rhel-root"
initrd="/boot/initramfs-0-rescue-67db13ba8cdb420794ef3ee0a8313205.img"
title="Red Hat Enterprise Linux (0-rescue-67db13ba8cdb420794ef3ee0a8313205) 8.6 (Ootpa)"
id="67db13ba8cdb420794ef3ee0a8313205-0-rescue"

To find out the file name of the default kernel, enter:

grubby --default-kernel
/boot/vmlinuz-4.18.0-372.9.1.el8.x86_64

To find out the index number of the default kernel, enter:

grubby --default-index
0

To change default kernel for booting:

grubby --set-default /boot/vmlinuz-4.18.0-372.9.1.el8.x86_64
grubby --set-default-index=0

Messing with kernel boot arguments

To add boot arguments to specific kernel:

grubby --args=console=ttyS0,115200 --update-kernel /boot/vmlinuz-4.18.0-372.9.1.el8.x86_64

To remove arguments:

grubby --remove-args="rhgb quiet" --update-kernel /boot/vmlinuz-4.18.0-372.9.1.el8.x86_64

Links:

  1. https://access.redhat.com/documentation/de-de/red_hat_enterprise_linux/8/html/managing_monitoring_and_updating_the_kernel/assembly_making-persistent-changes-to-the-grub-boot-loader_managing-monitoring-and-updating-the-kernel

Leave a Reply

Your email address will not be published. Required fields are marked *