• 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. hashcat: command not found
  2. “error: Bind to port 2222 on 0.0.0.0 failed: Permission denied” – error while starting sshd service on CentOS/RHEL
  3. How To Migrate Existing Iptables rules to Nftables In CentOS/RHEL 8
  4. featureCounts: command not found
  5. View files using – cat, more, tail, head and wc commands
  6. Permission Table for a File/Directory And File System Users Types
  7. pw-cli Command Examples in Linux
  8. dm-tool: command not found
  9. Hostname change not reflecting in sar report for CentOS/RHEL
  10. Beginner’s Guide to LVM (Logical Volume Management)

You May Also Like

Primary Sidebar

Recent Posts

  • qm Command Examples in Linux
  • qm wait Command Examples in Linux
  • qm start Command Examples in Linux
  • qm snapshot Command Examples in Linux

© 2023 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright