How do I permanently modify the kernel command line in RHEL 8?

Solution Verified - Updated

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-editenv command can be used to update the /boot/grub2/grubenv file:

    • RHEL 8:
  1. List the kernel parameters from the kernelopts variable:

     # grub2-editenv - list | grep kernelopts
    
  2. 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"
    
  3. Verify the newly added output:

    # grub2-editenv - list | grep kernelopts
    
  4. 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

  1. For checking details of default kernel:
# grubby --info DEFAULT
  1. For adding parameters on all kernels:
# grubby --update-kernel=ALL --args="argA argB"
  1. For removing parameters on all kernels:
# grubby --update-kernel=ALL --remove-args="argA argB"
  1. Reboot the system to apply the changes:
# reboot

Documentation

Additional Links for reference:

SBR
Components
Category

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.