The default boot loader in Redhat enterprise Linux 7 is grub2(GRand Unified Bootloader2). The “grub2” supports almost all the operating systems. The main configuration file for grub2 is /boot/grub2/grub.cfg. If you want to make any configuration change on the grub menu , you need to use the utility called “grub2-mkconfig” . If you manually edit the grub.cfg using vi or vim, grub will be corrupted. grub2-mkconfig read the /etc/default/grub file and it displays on the terminal. Here we will see that how we can update/edit the grub.cfg using grub2-mkconfig utility.
1. Login to the RHEL 7 system .
2. Check the current grub2 settings . (Look at only for timed-out )
[root@UnixArena-RHEL7 ~]# cat /boot/grub2/grub.cfg |grep timeout if [ x$feature_timeout_style = xy ] ; then set timeout_style=menu set timeout=5 # Fallback normal timeout code in case the timeout_style feature is set timeout=5 [root@UnixArena-RHEL7 ~]#
Here is the default “grub”
[root@UnixArena-RHEL7 ~]# cat /etc/default/grub GRUB_TIMEOUT=5 GRUB_DISTRIBUTOR="$(sed 's, release .*$,,g' /etc/system-release)" GRUB_DEFAULT=saved GRUB_DISABLE_SUBMENU=true GRUB_TERMINAL_OUTPUT="console" GRUB_CMDLINE_LINUX="rd.lvm.lv=rhel/root crashkernel=auto rd.lvm.lv=rhel/swap vconsole.font=latarcyrheb-sun16 vconsole.keymap=us rhgb quiet" GRUB_DISABLE_RECOVERY="true" [root@UnixArena-RHEL7 ~]#
3. Edit the /etc/default/grub and set the “GRUB_TIMEOUT=15” .
[root@UnixArena-RHEL7 ~]# grep TIMEOUT /etc/default/grub GRUB_TIMEOUT=15 [root@UnixArena-RHEL7 ~]#
4. Run the grub2-mkconfig to view the current settings. It will not going to over-write the existing configuration.It just like a dry run before committing the changes.
[root@UnixArena-RHEL7 ~]# grub2-mkconfig Generating grub configuration file ...
5. Commit the changes to grub.cfg.
[root@UnixArena-RHEL7 ~]# grub2-mkconfig > /boot/grub2/grub.cfg Generating grub configuration file ... Found linux image: /boot/vmlinuz-3.10.0-123.el7.x86_64 Found initrd image: /boot/initramfs-3.10.0-123.el7.x86_64.img Found linux image: /boot/vmlinuz-0-rescue-48314559db574327888736c3905146eb Found initrd image: /boot/initramfs-0-rescue-48314559db574327888736c3905146eb.img done [root@UnixArena-RHEL7 ~]#
6. Let me verify the grub.cfg file. We can see that timeout has been changed from 5 to 15 seconds.
[root@UnixArena-RHEL7 ~]# cat /boot/grub2/grub.cfg |grep timeout if [ x$feature_timeout_style = xy ] ; then set timeout_style=menu set timeout=15 # Fallback normal timeout code in case the timeout_style feature is set timeout=15 [root@UnixArena-RHEL7 ~]#
7. Let me reboot my system and verify it .
We have successfully edited the grub.cfg using grub2-mkconfig utility. The same way you can edit the other settings too if required.
Hope this article is informative to you .
Share it ! Comment it !! Be Sociable !!!
Leave a Reply