• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer navigation

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • Solaris
    • Oracle Linux
    • VCS
  • Interview Questions
  • Database
    • oracle
    • oracle 12c
    • ASM
    • mysql
    • MariaDB
  • DevOps
    • Docker
    • Shell Scripting
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

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

by admin

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.

# 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.

Filed Under: CentOS/RHEL 7, Linux

Some more articles you might also be interested in …

  1. How To Check World Wide Port Names (WWPN) of Tape Drives Attached to Linux host
  2. How to change a system’s machine-ID in Oracle Enterprise Linux 7
  3. What are Symbolic Links (Soft Links) and how to create them under Linux
  4. The locate Command in Linux
  5. sysctl setting for high load and prevent DDoS
  6. How to burn an ISO to CD or DVD using Wodim
  7. How to Check vendor of installed RPM packages in Linux
  8. How to change the path of the auditd log file /var/log/audit/audit.log
  9. Linux OS Service ‘iptables’
  10. How to use FTP under Linux to transfer files

You May Also Like

Primary Sidebar

Recent Posts

  • JavaFX ComboBox: Set a value to the combo box
  • Nginx load balancing
  • nginx 504 gateway time-out
  • Images preview with ngx_http_image_filter_module

© 2022 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright