Starting RHEL 7, GRUB2 is the default boot loader. The configurations and settings of GRUB2 are very different than the GRUB used in RHEL 6 and prior versions. The grubby command-line utility can be used to make persistent changes to the /boot/grub.cfg file. You can also modify /etc/default/grub file and use grub2-mkconfig to modify the arguments.
How to modify GRUB2 arguments using grubby
1. Use the grubby command to list all the kernel entries present.
# grubby --info=ALL index=0 kernel=/boot/vmlinuz-3.10.0-229.el7.x86_64 args="ro nomodeset crashkernel=auto rd.lvm.lv=vg_os/lv_root rd.lvm.lv=vg_os/lv_swap rhgb quiet LANG=en_US.UTF-8" root=/dev/mapper/vg_os-lv_root initrd=/boot/initramfs-3.10.0-229.el7.x86_64.img title=Red Hat Enterprise Linux Server 7.1 (Maipo), with Linux 3.10.0-229.el7.x86_64 index=1 kernel=/boot/vmlinuz-0-rescue-0c4400a0fc934267945bc23cb6c4440d args="ro nomodeset crashkernel=auto rd.lvm.lv=vg_os/lv_root rd.lvm.lv=vg_os/lv_swap rhgb quiet" root=/dev/mapper/vg_os-lv_root initrd=/boot/initramfs-0-rescue-0c4400a0fc934267945bc23cb6c4440d.img title=Red Hat Enterprise Linux Server 7.1 (Maipo), with Linux 0-rescue-0c4400a0fc934267945bc23cb6c4440d index=2 non linux entry
The –update-kernel option can be used to update a menu entry when used in combination with :
1. –args : to add new arguments.
2. –remove-args : to remove existing arguments.
How to remove an argument
Let us see an example to remove an argument from a menu entry. Following example shows how to remove the “rhgb quiet” arguments.
# grubby --remove-args "rhgb quiet" --update-kernel /boot/vmlinuz-3.10.0-229.el7.x86_64
List all the kernel entries and verify the changes done. You would note that the “rhgb quite” parameter for the kernel /boot/vmlinuz-3.10.0-229.el7.x86_64 is removed.
# grubby --info=ALL index=0 kernel=/boot/vmlinuz-3.10.0-229.el7.x86_64 args="ro nomodeset crashkernel=auto rd.lvm.lv=vg_os/lv_root rd.lvm.lv=vg_os/lv_swap LANG=en_US.UTF-8" root=/dev/mapper/vg_os-lv_root initrd=/boot/initramfs-3.10.0-229.el7.x86_64.img title=Red Hat Enterprise Linux Server 7.1 (Maipo), with Linux 3.10.0-229.el7.x86_64 index=1 kernel=/boot/vmlinuz-0-rescue-0c4400a0fc934267945bc23cb6c4440d args="ro nomodeset crashkernel=auto rd.lvm.lv=vg_os/lv_root rd.lvm.lv=vg_os/lv_swap rhgb quiet" root=/dev/mapper/vg_os-lv_root initrd=/boot/initramfs-0-rescue-0c4400a0fc934267945bc23cb6c4440d.img title=Red Hat Enterprise Linux Server 7.1 (Maipo), with Linux 0-rescue-0c4400a0fc934267945bc23cb6c4440d index=2 non linux entry
How to add an argument
Let us see an example of adding an argument to the menu entry. Let us add back the removed arguments “rhgb quiet” again. Use the “–args” option to add arguments to the GRUB2.
# grubby --args "rhgb quiet" --update-kernel /boot/vmlinuz-3.10.0-229.el7.x86_64
List all the kernel entries and verify the changes done.
# grubby --info=ALL index=0 kernel=/boot/vmlinuz-3.10.0-229.el7.x86_64 args="ro nomodeset crashkernel=auto rd.lvm.lv=vg_os/lv_root rd.lvm.lv=vg_os/lv_swap LANG=en_US.UTF-8 rhgb quiet" root=/dev/mapper/vg_os-lv_root initrd=/boot/initramfs-3.10.0-229.el7.x86_64.img title=Red Hat Enterprise Linux Server 7.1 (Maipo), with Linux 3.10.0-229.el7.x86_64 index=1 kernel=/boot/vmlinuz-0-rescue-0c4400a0fc934267945bc23cb6c4440d args="ro nomodeset crashkernel=auto rd.lvm.lv=vg_os/lv_root rd.lvm.lv=vg_os/lv_swap rhgb quiet" root=/dev/mapper/vg_os-lv_root initrd=/boot/initramfs-0-rescue-0c4400a0fc934267945bc23cb6c4440d.img title=Red Hat Enterprise Linux Server 7.1 (Maipo), with Linux 0-rescue-0c4400a0fc934267945bc23cb6c4440d index=2 non linux entry
Modifying parameters defined in /etc/default/grub
Another common entry we may need to modify is the timeout of grub menu, it is defined in /etc/default/grub. You can use the method described below to modify any other parameter defined in the file /etc/default/grub.
# cat /etc/default/grub GRUB_TIMEOUT=5 #### we have modified this from 5 seconds to 15 seconds GRUB_DEFAULT=saved GRUB_DISABLE_SUBMENU=true GRUB_TERMINAL_OUTPUT="console" GRUB_CMDLINE_LINUX="nomodeset crashkernel=auto rd.lvm.lv=vg_os/lv_root rd.lvm.lv=vg_os/lv_swap rhgb quiet" GRUB_DISABLE_RECOVERY="true"
You can edit the /etc/default/grub and modify to “GRUB_TIMEOUT=15”, then rebuild the grub.cfg by using the grub2-mkconfig command.
# grub2-mkconfig -o /boot/grub2/grub.cfg
Conclusion
The GRUB2 arguments can be modified using 2 methods :
1. Using grubby tool.
2. Modifying /etc/default/grub file and using comamnd grub2-mkconfig.
Also make sure you do not edit the file /boot/grub.cfg directly. This file gets updated automatically with the changes using the grubby tool.