How to manually modify the boot parameter in grub before the system boots
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
rootandswaplogical 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:
-
When the list of kernels appears at the beginning of the boot process, select the kernel to boot using the up/down arrow keys.
-
Press key
eto edit this entry. -
Use the arrow keys to move to the
linuxline. Append or change any necessary kernel options. -
Press Ctrl-x to boot the system with the modified kernel options.
-
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
-
When the list of kernels appear at the beginning of the boot process, select the kernel to boot using the up/down arrow keys.
-
Press key
eto edit this entry. -
Use the arrow keys to move to the
linuxline. Append or change any necessary kernel options. -
Press Ctrl-x to boot the system with the modified kernel options.
-
If the system boots properly, the changes will need to be saved in the grub configuration file. The
grub2-editenvutility 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 debugThe variable will be included in subsequent kernel re-installations, updates, but not
grub2-mkconfigoperations, hence it's recommended to also update/etc/default/grubmanually.
RHEL 7
-
When the list of kernels appear at the beginning of the boot process, select the kernel to boot using the up/down arrow keys.
-
Press key
eto edit this entry. -
Use the arrow keys to move to the
linux16line. Append or change any necessary kernel options. -
Press Ctrl-x to boot the system with the modified kernel options.
-
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 -
Append or change the kernel options on the
GRUB_CMDLINE_LINUXoption. Save the file. -
Run the
grub2-mkconfigcommand to regenerate thegrub.cfgfile:-
For BIOS systems:
# grub2-mkconfig -o /boot/grub2/grub.cfg -
For UEFI systems:
# grub2-mkconfig -o /boot/efi/EFI/redhat/grub.cfg
-
-
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
-
When the list of kernels appear at the beginning of the boot process, select the kernel to boot using the up/down arrow keys.
-
Press key
eto edit this entry. -
Using the arrow keys, select the line that needs modification.
-
Press the
ekey to edit the line. -
Edit the configuration as needed.
-
Press ENTER to accept the changes.
-
Press the
bkey to boot the system with the modified kernel options. -
If the system boots properly, the changes will need to be saved in
grub.conf. Editgrub.confwith the following command:# vi /etc/grub.conf -
Locate the kernel that was used in step 1.
-
Make the same changes to the kernel line for that kernel entry that was done in step 5.
-
Save the file.
-
Reboot the system and ensure the changes are working as expected.
Diagnostic Steps
- To make a persistent change to the kernel command line in RHEL5 and RHEL6, please 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, please see: How do I permanently modify the kernel command line in RHEL7?
- To make a persistent change to the kernel command line in RHEL8 and later, please see: How do I permanently modify the kernel command line in RHEL 8 and later?
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.