How can I get GRUB to boot straight into Ubuntu without showing a menu for 30 seconds?

I installed a brand new installation of Ubuntu 18.04.3 on a brand new machine today.

The manufacturers had installed a test installation of Windows but I told Ubuntu installer to erase it and overwrite with Ubuntu.

Now I'm finding that the GRUB menu appears and waits 30 seconds before defaulting to Ubuntu (the first option). It shows three options: 'Ubuntu,' 'Advanced options for Ubuntu' (which leads to a submenu with a choice of kernel versions), and lastly an option which causes the system to reset and bring up the BIOS settings. This isn't great as this machine is supposed to be standalone and this is making for a slow reboot time.

When I look in /etc/default/grub, I see that GRUB_TIMEOUT is already set to 0 and GRUB_TIMEOUT_STYLE is already set to "hidden", which is odd as the GRUB menu is staying up for 30 seconds on each boot.

Nevertheless, I've tried adding: GRUB_HIDDEN_TIMEOUT=0 GRUB_HIDDEN_TIMEOUT_QUIET=true (and running sudo update-grub) which made no difference. The grub menu still stays up for 30 seconds on each boot. I've tried it with just the GRUB_HIDDEN_TIMEOUT options active and the GRUB_TIMEOUT options commented; and with just the GRUB_TIMEOUT options active and the GRUB_HIDDEN_TIMEOUT options commented; none of that makes a difference.

I've tried adding: GRUB_DISABLE_OS_PROBER=true (and running sudo update-grub) which made no difference. Still get a grub menu for 30 seconds.

I've tried removing the x-bit from /etc/grub.d/30_os-prober, which still made no difference.

I've now tried running boot-repair from a live USB, which added several new options to the menu (each with names which are strings of letters with .efi endings). The menu is still shown for 30 seconds.

Is there anything else I can try to get GRUB to skip the menu and boot straight into Ubuntu?* Short of a reinstall?

Thanks in advance!


EDIT: I have isolated the problem. In /etc/grub.d/00_header there is:

if [ "$recordfail_broken" = 1 ]; then
  cat << EOF
if [ \$grub_platform = efi ]; then
  set timeout=${GRUB_RECORDFAIL_TIMEOUT:-30}
  if [ x\$feature_timeout_style = xy ] ; then
    set timeout_style=menu

...which results in these lines being in /boot/grub/grub.cfg...

if [ $grub_platform = efi ]; then
  set timeout=30
  if [ x$feature_timeout_style = xy ] ; then
    set timeout_style=menu

So even though there is no "recordfail" set in my grub environment (I have checked), apparently GRUB is declaring the recordfail system to be broken and is therefore defaulting to the recordfail default timeout of 30 seconds.

I have changed GRUB_RECORDFAIL_TIMOUT to 0 and now I get the faster boot time I wanted. However, now I obviously have no access to the boot menu if there are ever any problems booting.

It seems this happening is because the /boot dir isn't writeable because it's on an LVM partition. It's a known bug (here). But why would this happen on a brand new install...?


As a brute force method, you can create a file called /etc/grub.d/99_short_timeout with the following content:

cat << EOF
set timeout=1

and call

chmod a+x /etc/grub.d/99_short_timeout

afterwards. This will add set timeout=1 as the last line to grub.cfg.

The reason why I want to have at least one second timeout is that I want to keep the chance to change the GRUB selection. In my case, GRUB refused to skip the selection altogether for good reason: I use Btrfs, and GRUB cannot yet write to Btrfs partitions, so it cannot record a failed boot, and cannot distinguish at boot time whether it should offer me a rescue system.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.