Sunday, September 7, 2014

Update GRUB2 menu timeout on RHEL 7 Linux

The default settings for the GRUB2 timeout menu selection during the system boot is 5 seconds. To change this value open /etc/default/grub grub default config file. The content of the file looks similar the the one shown below: 

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"

To change the timeout settings simply updated the GRUB_TIMEOUT GRUB2 directive the to desired number of seconds your wish GRUB2 wait until you make your boot menu selection. For example to make GRUB 2 wait 20 seconds change this value to:

GRUB_TIMEOUT=20

In case that you do not wish GRUB 2 menu to appear / disable change the value to 0 seconds:
 
GRUB_TIMEOUT=0

Once you have updated your settings update GRUB2 settings using grub2-mkconfig command to create a new updated GRUB2 config file:
 
[root@rhel7 ~]# grub2-mkconfig -o /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-75387b56d72b48b380810499805ec28a
Found initrd image: /boot/initramfs-0-rescue-75387b56d72b48b380810499805ec28a.img
done
 

*Source: http://linuxconfig.org/update-grub2-menu-timeout-on-rhel-7-linux 

1 comment :

  1. Official documentation at Red Hat
    (https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/7/html/System_Administrators_Guide/sec-Customizing_GRUB_2_Menu.html)
    says:

    Important
    With the GRUB_TIMEOUT key set to 0 in the /etc/default/grub file, GRUB 2 does not display the list of bootable kernels when the system starts up. In order to display this list when booting, press and hold any alphanumeric key when the BIOS information is displayed; GRUB 2 will present you with the GRUB menu.

    However, if I set timeout=0, rebuild grub.cfg with grub2-mkconfig, and reboot,
    the menu does not show when 'any alphanumeric key' is pressed.
    This could become a big problem when you need to boot into runlevel 1
    (could happen when you cannot login any longer, not even on the console,
    when SELinux is set to enforcing and you have a context-fault in /etc/passwd or /etc/shadow).
    Suppose this happens at night in the datacenter. Handy to have a rescue usbstick/cdrom with you! :) )
    (I'll doublecheck the above again and will make a bug complaint if necessary).


    ReplyDelete