How to Modify GRUB2 Arguments with grubby CentOS / RHEL 7?

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.

 

NOTE: Modifying /boot/grub.cfg manually by vi is not recommended

 

How to modify GRUB2 arguments using grubby

 

1. Use the grubby command to list all the kernel entries present.

  

 

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.

  

 

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.

  

 

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.

  

 

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.

 

Was this answer helpful? 0 Users Found This Useful (0 Votes)