How to manually modify the boot parameter in grub before the system boots

Solution Verified - Updated

Environment

  • Red Hat Enterprise Linux 4
  • Red Hat Enterprise Linux 5
  • Red Hat Enterprise Linux 6
  • Red Hat Enterprise Linux 7
  • Red Hat Enterprise Linux 8
  • Red Hat Enterprise Linux 9
  • Red Hat Enterprise Linux 10

Issue

  • How do I manually modify the boot parameter in GRUB before system boot?
  • Need to test a change to the kernel boot options.
  • How to edit the kernel options in GRUB.
  • How to edit GRUB file after changing root and swap logical volume names?

Resolution

Occasionally, an incorrect configuration in grub.conf or grub.cfg can cause RHEL to fail to boot. If there are other kernels installed on the system, try one of those first. If the system still does not boot, the following next steps show how to manually modify the boot parameter to fix the problem and let the system boot successfully.

RHEL 9 and RHEL 10:

  1. When the list of kernels appears at the beginning of the boot process, select the kernel to boot using the up/down arrow keys.

  2. Press key e to edit this entry.

  3. Use the arrow keys to move to the linux line. Append or change any necessary kernel options.

  4. Press Ctrl-x to boot the system with the modified kernel options.

  5. If the system boots properly, the changes will need to be saved in the grub configuration file.

    • Execute the below command to modify the kernel command line permanently.

grubby --update-kernel=ALL --args=""

  • Reboot the system and ensure the changes are working as expected.

reboot

cat /proc/cmdline

RHEL 8

  1. When the list of kernels appear at the beginning of the boot process, select the kernel to boot using the up/down arrow keys.

  2. Press key e to edit this entry.

  3. Use the arrow keys to move to the linux line. Append or change any necessary kernel options.

  4. Press Ctrl-x to boot the system with the modified kernel options.

  5. If the system boots properly, the changes will need to be saved in the grub configuration file. The grub2-editenv utility is actually the recommended path to alter these variables. As a result, the following can be used. Appending an extra argument:

       # grub2-editenv - list | grep kernelopts
       kernelopts=root=/dev/mapper/rhel_example-root ro crashkernel=auto resume=/dev/mapper/rhel_example-swap rd.lvm.lv=rhel_example/root rd.lvm.lv=rhel_example/swap console=ttyS0
    
       # grub2-editenv - set "kernelopts=root=/dev/mapper/rhel_example-root ro crashkernel=auto resume=/dev/mapper/rhel_example-swap rd.lvm.lv=rhel_example/root rd.lvm.lv=rhel_example/swap console=ttyS0 debug"
    
       # grub2-editenv - list | grep kernelopts
       kernelopts=root=/dev/mapper/rhel_example-root ro crashkernel=auto resume=/dev/mapper/rhel_example-swap rd.lvm.lv=rhel_example/root rd.lvm.lv=rhel_example/swap console=ttyS0 debug
    

    The variable will be included in subsequent kernel re-installations, updates, but not grub2-mkconfig operations, hence it's recommended to also update /etc/default/grub manually.

RHEL 7

  1. When the list of kernels appear at the beginning of the boot process, select the kernel to boot using the up/down arrow keys.

  2. Press key e to edit this entry.

  3. Use the arrow keys to move to the linux16 line. Append or change any necessary kernel options.

  4. Press Ctrl-x to boot the system with the modified kernel options.

  5. If the system boots properly, the changes will need to be saved in the grub configuration file. To edit the grub config file, run this command:

    # vi /etc/sysconfig/grub
    
  6. Append or change the kernel options on the GRUB_CMDLINE_LINUX option. Save the file.

  7. Run the grub2-mkconfig command to regenerate the grub.cfg file:

    • For BIOS systems:

      # grub2-mkconfig -o /boot/grub2/grub.cfg
      
    • For UEFI systems:

      # grub2-mkconfig -o /boot/efi/EFI/redhat/grub.cfg
      
  8. Reboot the system and ensure the changes are working as expected. This can also be confirmed by running this command:

    # cat /proc/cmdline
    

RHEL 4, RHEL 5, or RHEL 6

  1. When the list of kernels appear at the beginning of the boot process, select the kernel to boot using the up/down arrow keys.

  2. Press key e to edit this entry.

  3. Using the arrow keys, select the line that needs modification.

  4. Press the e key to edit the line.

  5. Edit the configuration as needed.

  6. Press ENTER to accept the changes.

  7. Press the b key to boot the system with the modified kernel options.

  8. If the system boots properly, the changes will need to be saved in grub.conf. Edit grub.conf with the following command:

    # vi /etc/grub.conf
    
  9. Locate the kernel that was used in step 1.

  10. Make the same changes to the kernel line for that kernel entry that was done in step 5.

  11. Save the file.

  12. Reboot the system and ensure the changes are working as expected.

Diagnostic Steps

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.