Ubuntu – How to set GRUB timeout to 0 on Ubuntu 18.04

18.04bootgrub2

I tried to update my grub config file to timeout to 0 value, so OS starts quickly. I modified /etc/default/grub configuration file on my Ubuntu 18.04 and then ran:

sudo update-grub

and it didn't work. I also ran:

sudo grub-mkconfig
sudo update-grub

but they didn't work.

I searched a lot on the web to solve this issue, but all guides say to run the update-grub command to update grub by /etc/default/grub config file.
I don't know if is Ubuntu 18.04 that handles grub files in a different way, but I cannot update my grub with my parameters.

This is my /etc/default/grub file:

# 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=0
#GRUB_HIDDEN_TIMEOUT=0
GRUB_HIDDEN_TIMEOUT_QUIET=true
GRUB_TIMEOUT=0
GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"
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"

# Uncomment to disable graphical terminal (grub-pc only)
#GRUB_TERMINAL=console

# The resolution used on graphical terminal
# note that you can use only modes which your graphic card supports via VBE
# you can see them in real GRUB with the command `vbeinfo'
#GRUB_GFXMODE=640x480

# Uncomment if you don't want GRUB to pass "root=UUID=xxx" parameter to Linux
#GRUB_DISABLE_LINUX_UUID=true

# Uncomment to disable generation of recovery mode menu entries
#GRUB_DISABLE_RECOVERY="true"

# Uncomment to get a beep at grub start
#GRUB_INIT_TUNE="480 440 1"

Best Answer

In /boot/grub/grub.cfg file there is a condition, almost at the end of the file, that sets the timeout to 10 if the timeout is set to 0. In other words, if you set the timeout to 0 in your /etc/default/grub and then update grub, the condition above reset it to 10 seconds.

if [ "${timeout}" = 0 ]; then
     set timeout=10
fi

However, /boot/grub/grub.cfg is a read-only file and I cannot remove that condition. I made some tests with different values of the timeout in /etc/default/grub. I tried with 1ms (0.001), 0.1s and 1s and I found out that values below 1 (like 0.1 and 0.001) work in the same way and almost like timeout set to 0.

Related Question