How do I permanently modify the kernel command line on RHEL 7?

Solution Verified - Updated

Environment

  • Red Hat Enterprise Linux (RHEL) 7
  • GRUB2 boot loader

Issue

  • How do I modify the kernel command line (and, thus, kernel boot parameters) in Red Hat Enterprise Linux 7 with GRUB2 installed as a boot loader?

Resolution

For RHEL7:

Alternative 1:

  1. Make copy of the GRUB2 configuration files as a precaution:

    For a BIOS-based system:

    # cp /etc/default/grub /etc/default/grub-backup            
    # cp /boot/grub2/grub.cfg /boot/grub2/grub.cfg-backup
    

    For a UEFI-based system:

    # cp /etc/default/grub /etc/default/grub-backup
    # cp /boot/efi/EFI/redhat/grub.cfg /boot/efi/EFI/redhat/grub.cfg-backup
    
  2. Open the /etc/default/grub file for editing:

    # vi /etc/default/grub
    

    This file contains multiple GRUB2 options. Kernel boot parameters are specified by the GRUB_CMDLINE_LINUX option.

  3. Once the file is edited, save it and run the command specified below to generate a new grub.cfg file:

    For a BIOS-based system:

    # grub2-mkconfig -o /boot/grub2/grub.cfg
    

    For a UEFI-based system:

    # grub2-mkconfig -o /boot/efi/EFI/redhat/grub.cfg
    
  4. Finally, reboot the system to apply the changes:

    # systemctl reboot
    

Alternative 2: Using grubby command:

  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

Additional Notes:

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.