How do I permanently modify the kernel command line in RHEL 8?
Environment
- Red Hat Enterprise Linux 8
- GRUB2 boot loader
Issue
- The boot loader Grand Unified Boot Loader (GRUB2) in RHEL 8 differs from the GRUB2 in RHEL 7.
- How do I modify the kernel command line (and, thus, kernel boot parameters) in Red Hat Enterprise Linux 8?
Resolution
Method 1: Using grub2-editenv
-
grub2-editenvcommand can be used to update the/boot/grub2/grubenvfile:- RHEL 8:
-
List the kernel parameters from the
kerneloptsvariable:# grub2-editenv - list | grep kernelopts -
The following commands can be used to add/remove/modify the kernel command line parameters:
# grub2-editenv - set "$(grub2-editenv - list | grep kernelopts) <NEW_PARAMETER>" OR # grub2-editenv - set "kernelopts=root=/dev/mapper/rhel-root ro crashkernel=auto resume=/dev/mapper/rhel-swap rd.lvm.lv=rhel/root rd.lvm.lv=rhel/swap rhgb quiet" -
Verify the newly added output:
# grub2-editenv - list | grep kernelopts -
Reboot the system to apply the changes:
# systemctl reboot
Note: If you have to abort the changes then you can unset the kernelopts with the following command:
# grub2-editenv - unset kernelopts
Note: The older method of modification of kernel command line from file /etc/default/grub followed by the rebuilding of grub (grub2-mkconfig) is still possible. However, it is recommended to use the ways mentioned in this solution for modifying the kernel command line on RHEL 8.
Method 2: Using grubby
- For checking details of default kernel:
# grubby --info DEFAULT
- For adding parameters on all kernels:
# grubby --update-kernel=ALL --args="argA argB"
- For removing parameters on all kernels:
# grubby --update-kernel=ALL --remove-args="argA argB"
- Reboot the system to apply the changes:
# reboot
Documentation
- The RHEL 8 documentation for modifying kernel command line parameters.
Additional Links for reference:
-
To make a persistent change to the kernel command line in RHEL9 and RHEL10, see: How to modify the kernel command-line in Red Hat Enterprise Linux 9 and 10
-
To make a persistent change to the kernel command line in RHEL5 and RHEL6, see: How do I permanently modify the kernel command line in RHEL5 and RHEL6?
-
To make a persistent change to the kernel command line in RHEL7, see: How do I permanently modify the kernel command line in RHEL7?
-
To make a one-time, non-persistent change at boot, see: How to manually modify the boot parameter in grub before the system boots
This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.