How to disable grub menu at boot time in Ubuntu 20.04?
Solution 1
Tested with Dual boot of 2 Ubuntu 20.04 OS'es
Edit the below line in the file /etc/default/grub
file
GRUB_TIMEOUT=10
like this
GRUB_TIMEOUT=0
and run the below command
sudo update-grub
this makes the timeout to 0 with condition that if there is Single OS it will stick to 0 otherwise it will be overwrite to 10.
In the /etc/grub.d/30_os-prober
file, change the line
quick_boot="1"
to
quick_boot="0"
This will prevent in multi OS'es cases from changing the timeout value to 10seconds..
see the function "adjust_timeout" from the file /etc/grub.d/30_os-prober
prefix="/usr"
exec_prefix="/usr"
datarootdir="/usr/share"
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
}
When you want to see grub menu, pressing the Esc
key at rite time will show you. (rite time varies based on conditions, generally after the BIOS menu hand overs to grub menu time)
In case if you wish to change Default OS, you can set from the same file /etc/default/grub
.
for the first time, get to the grub menu by hitting Esc
at the rite time. Then count the number starting from 0 from top to list your favorite OS Entry..
For example, I have two 20.04 OS'es.. one in /dev/sda2
and other in /dev/sda6
/dev/sda2
is the default one. If I want to make the one in /dev/sda6
as the default OS, I need to find its number like below..
So, its position is at number 2.
Edit the file /etc/default/grub
and change the line
GRUB_DEFAULT=0
to
GRUB_DEFAULT=2
then run the below command
sudo update-grub
System will boot straight to Ubuntu 20.04 on /dev/sda6
Solution 2
Solution / tl;dr
echo 'set timeout_style=hidden
set timeout=0' | sudo tee /boot/grub/custom.cfg
Explanation
Though UnKNOWn's approach does indeed work, the modification of files installed by the base system should be avoided, if possible. In this case (i. e. Ubuntu 20.04), apt-file shows that /etc/grub.d/30_os-prober
belongs to the package grub-common
(this is also true for all files located in /etc/grub.d/
, which are used by the update-grub
command to compile the final GRUB configuration file):
Output of "apt-file search /etc/grub.d/30_os-prober"
If the package grub-common
gets updated in the future, apt would detect the change and prompt you to decide what it should do (as both options - the file modified by you as well as the unmodified file from the distributor - are valid). In the worst-case scenario you would have to compare and merge the file contents manually.
So, what are our options if we want to hide the GRUB menu in a multiboot environment? For once, the grub-common
package only wants to make sure that each and every user can switch between the installed operating systems. Because of that, the script /etc/grub.d/30_os-prober
contains the following code snippet:
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
}
This script (which is evaluated once the update-grub
command gets executed) basically allows you to set a custom timeout even for multiboot environments - but it will not allow a timeout of 0, as novice users would perhaps not know how to boot their other operating systems without an obvious menu. This means that you could set GRUB_TIMEOUT
to 1, and so the GRUB menu would show up for just a second before booting the default boot option.
But how can we hide the GRUB menu for good without touching files installed by system packages? Luckily, the grub-common
package provides a facility to apply one-off settings. Have a look at the last file evaluated by the update-grub
command, /etc/grub.d/41_custom
:
#!/bin/sh
cat <<EOF
if [ -f \${config_directory}/custom.cfg ]; then
source \${config_directory}/custom.cfg
elif [ -z "\${config_directory}" -a -f \$prefix/custom.cfg ]; then
source \$prefix/custom.cfg;
fi
EOF
OK, so a file named custom.cfg
, which must be placed in the same location as the actual GRUB configuration file (/boot/grub/grub.cfg
), gets sourced every time the GRUB configuration file gets evaluated (i. e. at boot time). So let us add our desired settings to this file (/boot/grub/custom.cfg
):
GRUB will now hide the menu and instead boot the default boot option immediately. Other operating systems can still be booted by using the UEFI.
Related videos on Youtube
Sanjay Prajapat
Updated on September 18, 2022Comments
-
Sanjay Prajapat over 1 year
I have installed Ubuntu 20.04 alongside Windows. When I boot the system, it shows the grub menu for 10 seconds to choose between Ubuntu and Windows. I don't want that menu, just want to boot it up right after pressing the power button. I have looked into this thread and added
GRUB_HIDDEN_TIMEOUT_QUIET=true
and even changedGRUB_TIMEOUT
to0
and then ransudo update-grub
. But it didn't work, menu is still being shown at boot time. 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_TIMEOUT_STYLE=hidden 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"
How do I disable it?
-
UnKNOWn about 4 yearsDoes this answer your question? Dual boot Windows 10 & Ubuntu 18.04 - How to tell grub not to show and boot directly to Windows 10
-
thorstorm about 4 yearsWhat happens if you set
GRUB_TIMEOUT=1
. Does the boot wait time reduce to 1 second? -
Pilot6 about 4 yearsDoes it show for 10 or 20 seconds? Is system installed on
lvm
orbtrfs
?
-
-
AndresR over 3 yearsCan you explain a little bit "Other operating systems can still be booted by using the UEFI." Is there another way to select boot OS?
-
opx over 3 yearsWell, many UEFI implementations are able to list the available operating systems (since all of them will store the files required for their boot process on a common ESP, short for EFI System Partition). Most of the time they will also allow you to select the operating system that should boot from this list once you have entered the UEFI user interface. Note that the steps needed to enter the UEFI user interface differ between vendors and implementations. Most of the time you will have to press Escape, Delete or one of the function keys on system startup.