11

Answers to a very old question suggest to edit

/etc/default/grub

That file has the following contents:

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"
GRUB_CMDLINE_LINUX=""

The timeout I'm witnessing when booting the system is 10 seconds. According to the configuration file it's 0 seconds though. So, where is the timeout actually defined in Ubuntu 20.04?

6
  • 1
    All the Ubuntu versions I have installed have had 10 as default & I change to 3. Zero is not recommended as then you may not be able to get into grub to easily resolve a boot issue.
    – oldfred
    Aug 2, 2020 at 22:31
  • I don't want to set it to zero. It WAS already at zero. So, where do the 10 seconds I'm seeing come from? Aug 2, 2020 at 22:33
  • Every new install has that, not then sure how you got 0. Did you run some software that modifies grub in some way? I would just change back to 10 if that is what you want or whatever number you do want.
    – oldfred
    Aug 2, 2020 at 22:52
  • I'd say I didn't do any configuration. But I'll just try to modify the value and see what happens. Aug 2, 2020 at 22:53
  • It's really kind of a bug in GRUB. Either set GRUB_TIMEOUT=3, or something less than 10... or if you REALLY want no GRUB menu, let me know, and I'll give you that fix. Are you dual-booting? Start comments to me with @heynnema or I'll miss them.
    – heynnema
    Aug 2, 2020 at 23:22

5 Answers 5

8

It's kind of a bug in GRUB.

In /etc/grub.d/30_os-prober, here's the code snippet that causes the problem...

quick_boot="1"

export TEXTDOMAIN=grub
export TEXTDOMAINDIR="${datarootdir}/locale"

. "$pkgdatadir/grub-mkconfig_lib"

found_other_os=

adjust_timeout () {
  if [ "$quick_boot" = 1 ] && [ "x${found_other_os}" != "x" ]; then
    cat << EOF
set timeout_style=menu
if [ "\${timeout}" = 0 ]; then
  set timeout=10
fi
EOF
  fi
}

To change/fix the 10 second timeout, edit /etc/grub.d/30_os-prober with:

sudo -H gedit /etc/grub.d/30_os-prober

and either:

  1. set quick_boot="1" to quick_boot="0"
  2. set set timeout=10 to set timeout=3

Note: or edit /etc/default/grub and set GRUB_TIMEOUT=3, or something between 1 and 10.

sudo update-grub

Note: See here for more details/options.

8
  • So if only Ubuntu or 30_osprober finds no other systems to boot, it uses a quick_boot setting and sets it to 0? I have never had 0, but always have had multiple boot. I turn off os-prober, usually right after install and use my own 40_custom. But I also change grub timeout to 3. Historically I have seen many recommendations to never use 0 as then you may not be able to get into grub menu if you need to.
    – oldfred
    Aug 3, 2020 at 3:30
  • 1
    @oldfred quick_boot=0 is not the same as GRUB_TIMEOUT=0. Revisit the code snippet to fully understand what it's trying to do there.
    – heynnema
    Aug 3, 2020 at 14:27
  • That code isn't buggy, it's working as intended. If you open /etc/defaults/grub and set GRUB_TIMEOUT to anything other than zero, it should work. The reason it's increasing the timeout is to give the user a chance to pick a different OS. That perfectly sensible, and doesn't happen if the user overrides the default value of 0.
    – jpaugh
    Dec 4, 2020 at 1:54
  • @jpaugh See askubuntu.com/questions/879881/…
    – heynnema
    Dec 4, 2020 at 15:15
  • This did not work. Timeout still stuck at ~20 seconds. GRUB_TIMEOUT does nothing to change that.
    – Dave
    Mar 27, 2022 at 19:01
2

I am using update-grub 2.02-2ubuntu8.23.

In the file /etc/default/grub I added:

GRUB_RECORDFAIL_TIMEOUT=5

The default value was 30 seconds for efi.

When I set the value to 5, it worked and I no longer have to wait 30 seconds if I don't respond to the menu.

It may be that GRUB_RECORDFAIL_TIMEOUT does not apply to all versions of grub. I could not find it documented. To see if it applies to your version of grub, search /etc/grub.d, which is a set of files for creating the grub configuration:

$ grep GRUB_RECORDFAIL_TIMEOUT *
00_header:  set timeout=${GRUB_RECORDFAIL_TIMEOUT:-30}
00_header:  set timeout=${GRUB_RECORDFAIL_TIMEOUT:-30}
2
  • In spite of having lived with GRUB since the beginning, its documentation regarding menu modes and timeouts still makes my brain hurt. I don't even have to understand what "recordfail" means, though. I can see the immediate effect of setting GRUB_RECORDFAIL_TIMEOUT=5 in /etc/default/grub on the timeout values in /boot/grub/grub.cfg after running update-grub, and can confirm this solves the problem. Therefore, all the points to you sir. Sep 3 at 19:54
  • This is the most "correct" answer here, because it doesn't modify files in /etc/grub.d that are very likely to be overwritten by a subsequent package update. Sep 3 at 19:55
1

It's important to understand if some cases like EFI Boot active or ex-dual boot when you remove one of these partitions and grub menu continuing to show on startup the correct file to change these situations it's in the boot Grub. In case this before answer procedures doesn't work, You need to change the line 119 value in "/boot/grub". If you dont no, the command is "sudo gedit /boot/grub".

In the part:

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

Change the second line set timeout=30 value 30 to 00, and save (you need to be a root) and restart.

1
  • /boot/grub is a folder, not a file. You shouldn't edit anything in /boot. Your edit command should be sudo -H gedit... or you may end up with a login loop.
    – heynnema
    Aug 30, 2021 at 13:48
0

For me, i had to:

chmod uog+w /boot/grub/grub.cfg

...in order to make it writable, you might want to only hit o+w if there are others who use the machine, as the command above gives everyone write access to the file. Then, after hitting gedit /boot/grub/grub.cfg

i changed line 111 (set timeout=-1) to what i wanted:

 if [ x$feature_timeout_style = xy ] ; then
    set timeout_style=hidden
    set timeout=-1

This eliminates the timeout, if you just want a more or less grub time, just change the value to number of seconds without the "-".

-1

Answer from Thiago Lucio did the trick for me.

I have to change

"if [ \$grub_platform = efi ]; then
  set timeout=${GRUB_RECORDFAIL_TIMEOUT:-30}"

to

"if [ $grub_platform = efi ]; then
  set timeout=3" 

in /etc/grub.d/00_header

I use a dual boot with EFI.

1
  • Thiago's answer also worked for me. That said, you should remove the backslash before $grub_platform in your first example and those with less experience should be advised not to include quotes lest they're tempted to copy and paste from your examples (or you should consider removing them from your examples.
    – user47108
    Nov 13, 2021 at 15:05

You must log in to answer this question.

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