How can I get my GRUB menu to be hidden, AND have the shift or esc keys show the hidden GRUB menu at boot time

OK folks, here's the answer... to obtain a hidden GRUB menu in dual-boot configurations... two edits... and a sudo update-grub...

Edit #1

To obtain a hidden GRUB menu in a multi-boot configuration, we first need to edit /etc/default/grub. Open this file using the below command:

sudo editor /etc/default/grub

Once the file is open, replace these lines

GRUB_HIDDEN_TIMEOUT_QUIET=true
#GRUB_HIDDEN_TIMEOUT=0
GRUB_TIMEOUT=10

with these:

GRUB_HIDDEN_TIMEOUT_QUIET=false
GRUB_TIMEOUT_STYLE=countdown
#GRUB_HIDDEN_TIMEOUT=0
GRUB_TIMEOUT=3

This will cause GRUB to display a 3 second countdown timer on the screen. By doing this, a user can hit the Esc key to bring up the default menu. Otherwise, the default OS will boot.

If you wish that the default OS should be set to the last-booted OS, add the below two lines under the "GRUB_TIMEOUT=3" shown above:

GRUB_DEFAULT=saved    # change an existing line to this
GRUB_SAVEDEFAULT=true # add this line

Edit #2

Next, the OS prober needs to be updated to disable the quick_boot feature. To do this, open /etc/grub.d/30_os-prober in your favorite editor and change the below line (line 23 in 17.04) by replacing the 1 with a 0:

quick_boot="1"

When you're done, the line should read like:

quick_boot="0"

Save the files and then run the below command to reconfigure the bootloader and to apply your changes:

sudo update-grub

I believe this issue may be due to multiple OS according to this excerpt from Grub2 wiki:

If no other operating system is detected GRUB 2 will boot straight into the default operating system and no menu will be displayed. If another operating system is detected the GRUB 2 menu will display.

AND

Saving an OS can be achieved by running sudo grub-set-default if GRUB_DEFAULT=saved is set in /etc/default/grub. It may also be saved if GRUB_SAVEDEFAULT=true is also set in /etc/default/grub. In this case, the default OS remains until a new OS is manually selected from the GRUB 2 menu or the grub-set-default command is executed.

The Grub2 Wiki also states: Note: There is a longstanding confirmed bug on the hidden menu feature in GRUB 1.97 to GRUB 1.99. The menu may not hide as specified in the description on this page. While editing the 30_os-prober script can fix this issue, it is beyond the scope of this page.

As a work around you can set the GRUB_TIMEOUT="1"and you will only see the menu for 1 second. If I need to switch to another OS I simply hit the arrow down key within that second and the menu will appear until I make a choice.

There may be a potential syntax problem associated with the bug. I am not a Grub2 expert but in my grub file every command line ends with ="some quoted setting" I remember from my coding days that "quotes" were to pass a string where as non quotes were passing simple numeric values to the variables. I am not UP in new code techniques. e.g. Here is some of my grub output:

# If you change this file, run 'update-grub' afterwards to update
# /boot/grub/grub.cfg.
# For full documentation of the options in this file, see:
#   info -f grub -n 'Simple configuration'

GRUB_DEFAULT="Ubuntu"
#GRUB_HIDDEN_TIMEOUT="0"
GRUB_HIDDEN_TIMEOUT_QUIET="true"
GRUB_TIMEOUT="1"
GRUB_DISTRIBUTOR="`lsb_release -i -s 2> /dev/null || echo Debian`"
GRUB_CMDLINE_LINUX_DEFAULT=""
GRUB_CMDLINE_LINUX=""

# Uncomment to enable BadRAM filtering, modify to suit your needs
# This works with Linux (no patch required) and with any kernel that obtains
# the memory map information from GRUB (GNU Mach, kernel of FreeBSD ...)
#GRUB_BADRAM="0x01234567,0xfefefefe,0x89abcdef,0xefefefef"

I'm looking into this Grubbug :) for more info as well as This Bug Both of these are Grub2 related 2yrs old. Some of this could be related to the MBR code before the handoff to Grub2


  1. I guess you want to try 'everything' available via /etc/default/grub. Did you read this link,

    help.ubuntu.com/community/Grub2/Setup#Configuring_GRUB_2

  2. I suggest that you try removing the following lines from /boot/grub/grub.cfg,

    ...
    set timeout_style=menu
    if [ "${timeout}" = 0 ]; then
      set timeout=10
    fi
    ### END /etc/grub.d/30_os-prober ###
    

    Yes, I know, you would have to do it every time update-grub has run, but you can make a script for it.

Tags:

Menu

Grub2