1

I have set GRUB to be fully hidden. However, it does sometimes randomly show when I am booting. What could be causing this?

Contents of etc/default/grub

GRUB_DEFAULT="0"
GRUB_TIMEOUT_STYLE="hidden"
GRUB_TIMEOUT="0"
GRUB_DISTRIBUTOR="`lsb_release -i -s 2> /dev/null || echo Debian`"
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash nouveau.modeset=0"
GRUB_CMDLINE_LINUX=""
GRUB_HIDDEN_TIMEOUT="0"
GRUB_DISABLE_OS_PROBER="true"

Ubuntu 18.04. is the only installed operating system. I am using UEFI boot with secure boot disabled.

phanky5
  • 1,886

2 Answers2

0

You have

GRUB_TIMEOUT_STYLE="hidden"

in /etc/default/grub but you also have the line

GRUB_HIDDEN_TIMEOUT="0"

in /etc/default/grub.

With the first one you tell Grub to hide the menu and with the latter you tell Grub to show the menu after 0 seconds.

You should remove the line

 GRUB_HIDDEN_TIMEOUT="0"

from /etc/default/grub and then run sudo update-grub.

Here the essential part from the GRUB Manual:

‘GRUB_HIDDEN_TIMEOUT’

Wait this many seconds before displaying the menu. If ESC is pressed during that time, display the menu and wait for input according to ‘GRUB_TIMEOUT’. If > a hotkey associated with a menu entry is pressed, boot the associated menu entry immediately. If the timeout expires before either of these happens, display the menu for the number of seconds specified in ‘GRUB_TIMEOUT’ before booting the default entry.

If you set ‘GRUB_HIDDEN_TIMEOUT’, you should also set ‘GRUB_TIMEOUT=0’ so that > the menu is not displayed at all unless ESC is pressed.

This option is unset by default, and is deprecated in favour of the less confusing ‘GRUB_TIMEOUT_STYLE=countdown’ or ‘GRUB_TIMEOUT_STYLE=hidden’.


Another possibility is Grub's built-in recordfail-function. Whenever a menu-entry is chosen (manually or automatically), Grub will set the variable recordfail=1 and saves it in /boot/grub/grubenv.

During boot the variable will be unset by systemd if the boot is successful, if the boot fails, the variable will remain unchanged in /boot/grub/grubenv.

Everytime time Grub starts, Grub will read /boot/grub/grubenv and checks if recordfail is set to 1. So Grub will know if the last boot succeeded or not. If the last boot wasn't successful, Grub will override your settings from /etc/default/grub to display the boot menu for 30 seconds.

You can check the content of /boot/grub/grubenv with

cat /boot/grub/grubenv
mook765
  • 15,925
  • Thank you for pointing this out. It looks like this fixed it. – phanky5 Sep 21 '19 at 14:59
  • No, sorry I have to retract that. Grub still comes up at random. Any other suggestions? – phanky5 Sep 22 '19 at 18:14
  • @phanky5 Does it really happen randomly or can you determine special circumstances, e.g the boot menu appears after the system failed to boot? – mook765 Sep 22 '19 at 18:43
  • I will take some paper notes and report back here. This may take a few days to figure it out. – phanky5 Sep 23 '19 at 07:57
  • After you last comment this was easy to figure out. It was a known issue with Chrome browser not shutting down properly: https://bugs.chromium.org/p/chromium/issues/detail?id=429404#c74 https://askubuntu.com/questions/1103495/want-chrome-close-normally-when-shutdown-or-reboot-ubuntu-18-04

    I have moved to Firefox and the problem is now fixed. Thank you for your help.

    – phanky5 Sep 23 '19 at 08:53
0

The problem seemed to occur when Grub went into recovery mode after the system or a program didn't shut down properly.

To prevent Grub from showing in those circumstances add this line to /etc/default/grub

GRUB_RECORDFAIL_TIMEOUT="3"

Set the timeout value to anything you like. I have set it to 3 to still have the option to access group in case of system failure. Setting the value to 0 will prevent Grub from showing altogether.

After making the changes run this command to apply them: sudo update-grub

phanky5
  • 1,886