14

I'm running Ubuntu 16.10, and I'm trying to hide my GRUB menu at power on/boot time, and wish the menu to appear only when I hit the Shift or Esc keys.

I change the appropriate options in /etc/default/grub and it still won't hide the menu.

In researching this, I found this post from 2013 GRUB hidden menu not working that indicates that the problem has been around for a while, and suggests a change to /etc/grub.d/30_os-prober which I'd rather not do. That code suggests that since its found multiple OS's, it's going to set the GRUB_TIMEOUT=10 anyway.

Here's a snippet of what I have now in /etc/default/grub... a menu with a 10 second countdown...

GRUB_DEFAULT=saved
GRUB_SAVEDEFAULT=true
GRUB_HIDDEN_TIMEOUT_QUIET=true
#GRUB_HIDDEN_TIMEOUT=0
GRUB_TIMEOUT=10
GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"

If I uncomment #GRUB_HIDDEN_TIMEOUT=0, then sudo update-grub insists that I also set GRUB_TIMEOUT=10 to GRUB_TIMEOUT=0. I do that, and I still see the GRUB menu.

In terminal, typing info -f grub -n 'Simple configuration' describes the various options, and at the very end of the info, it shows that some of the current commands have been depreciated, and suggests that the newer replacements are better.

Does anybody know how I can get my GRUB menu to hide in 16.10 AND have it recognize Shift or Esc keys at boot time?

14
  • I'm glad you asked this. I couldn't get mine to work either, and this confirms that it is because of the box being a dual booter. Feb 7, 2017 at 0:57
  • 1
    @OrganicMarble The problem does have to do with multiple OS's. To test, I did modify that portion of code in /etc/grub.d/30_os-prober, and although I got no menu, I wasn't able to force a menu with shift or esc at boot time. Still working on it.
    – heynnema
    Feb 7, 2017 at 0:59
  • I added some more info on bugs related to yours in my answer, they may help you understand the nature of the problem more thoroughly. I am also looking at Grub2 code - trying to help :) Feb 7, 2017 at 20:17
  • Try using Grub Customizer if you haven't, General Setting Tab in this order - 1 Uncheck the box "look for other operating systems" and 2 Uncheck "show menu" then save. Test that and see if "Shift" will bring up the menu and then also what happens if nothing is pressed. Feb 7, 2017 at 20:49
  • I can understand that you'd rather not modify /etc/grub.d/30_os-prober but I really don't see the harm. You can keep a copy backed up or #Comment your changes so that you can reverse them if need be. The workaround you found seems the most reasonable solution at the moment.
    – Elder Geek
    Feb 9, 2017 at 9:52

3 Answers 3

11

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 -H gedit /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
6
  • That did it! +1. Feb 11, 2017 at 15:08
  • Looks like a good solution :) Now I have a simple question about it. If you change the GRUB_TIMEOUT from "3" to "1" Will you boot faster. And can you provide links, if any, where one can read how this code works. I want to understand what this code is doing and its sequence of function calls etc. Much appreciated. It is nice when you can solve your own questions - good job on that. Feb 11, 2017 at 19:21
  • @xtrchessreal yes, changing the 3 to a 1 makes it 2 seconds shorter. I figured that 3 seconds was enough time for me to get my hand over to the Esc key, if I wanted to. You can look at info -f grub -n 'Simple configuration' for more info.
    – heynnema
    Feb 11, 2017 at 19:30
  • +1 for Q and +1 for A. Last two nights I've been googling this with all kinds of hair brained modifications to 30_os-proper, creating 31_blah_blah and creating 40_custom all to no avail. This is in AU, ArchLinux, Fedora and many other places.If you want more votes I'd suggest tracking down all the wrong answers here in AU (there are lots) and Voting to close them as duplicates of this one then ping me (@ me) in AU general chatroom with a link to the duplicate and I'll vote it too. Thanks for this great research and working solution! :) Apr 19, 2017 at 23:19
  • @WinEunuuchs2Unix thanks for the nice comment, and the votes! I myself did lots of research before I found that nobody had an elegant solution, or any solution at all... but I was determined :-)
    – heynnema
    Apr 19, 2017 at 23:33
5
+50
  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.

6
  • Thanks for your response. I'll take a look at that link. I also had found a way to modify /etc/grub.d/30_os-prober so that I wouldn't have to edit grub.cfg each time.
    – heynnema
    Feb 7, 2017 at 22:42
  • This makes sense to me, as in a multiboot system it looks like this code changes the timeout back to 10 from 0 Which seems to defeat HIDDEN_TIMEOUT....
    – Elder Geek
    Feb 10, 2017 at 17:20
  • @heynnema could you post your changes to os-prober? When I looked at the link in your question and compared it to the code in my os-prober, the line numbers did not make sense, so I assume os-prober has changed since then, and I was afraid to mess with it. Feb 10, 2017 at 17:30
  • 1
    @OrganicMarble see the update to my question. Maybe you can try some/all of my mods and see what you come up with.
    – heynnema
    Feb 10, 2017 at 17:55
  • @sudodus please see my answer
    – heynnema
    Feb 11, 2017 at 14:27
4

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

7
  • Thanks for your response. I already am using the SAVEDEFAULT method. TIMEOUT=1 certainly shortens the menu appearance time. The problem does have to do with multiple OS's. To test, I did modify that portion of code in /etc/grub.d/30_os-prober, and although I got no menu, I wasn't able to force a menu with shift or esc at boot time.
    – heynnema
    Feb 7, 2017 at 0:37
  • Those bugs you linked don't seem relevant or am I missing something?
    – Elder Geek
    Feb 9, 2017 at 9:44
  • 1
    @ElderGeek with regard to bug #1401318 the person the bug is assigned to TJ explains the behavior from the MBR to Grub as he states "sleep --interruptable $timeout" etc. If you read all of his statements in the bug comments I think you will see what at least part of the problem is. He is also assigned to bug #425979 which is similar in issues. Both bugs dealing with holding shift key to bring Grub menu NOT working when set to be hidden. This is what the OP is trying to figure out as well. I hope this clarifies why the links are in my posted answer. Feb 9, 2017 at 19:39
  • Pardon my confusion. I read the question as saying "how I can get my GRUB menu to hide" Thank you for clarifying. I must have missed that comment.
    – Elder Geek
    Feb 9, 2017 at 19:42
  • @ElderGeek actually, the question is, "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". I've gotten it to hide. I haven't gotten the shift or esc keys to work. Apparently this problem goes way back to 2013 or before, and only effects multi-boot configurations.
    – heynnema
    Feb 10, 2017 at 16:54

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .