Hide GRUB2 menu UNLESS you hold down Shift key: how to make this happen?
Solution 1:
I think that I found a simpler resolution. Modify the following lines in the file /etc/default/grub :
GRUB_HIDDEN_TIMEOUT=0.0
GRUB_TIMEOUT=0.0
Of course we finally run an update-grub. It works on my PC.
Solution 2:
This is for Ubuntu 16.04.
I solved this with a little combination of some of the answers found above, so it is not necessary to modify 30_os-prober, avoiding future merges when the grub package is updated...
Hope it helps.
Changed some variables in /etc/default/grub to reflect what I want;
GRUB_DEFAULT=4
GRUB_HIDDEN_TIMEOUT=5
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=""
GRUB_FORCE_HIDDEN_MENU="true"
export GRUB_FORCE_HIDDEN_MENU
Then created a new file;
sudo touch /etc/grub.d/50_hidemenu
sudo chmod +x /etc/grub.d/50_hidemenu
filled it with this content;
#!/bin/sh
cat <<EOF
if [ "x\${timeout}" != "x-1" ]; then
if keystatus; then
if keystatus --shift; then
set timeout=-1
else
set timeout=0
fi
else
if sleep --interruptible ${GRUB_HIDDEN_TIMEOUT} ; then
set timeout=0
fi
fi
fi
EOF
and updated grub;
sudo update-grub
Cheers.
Solution 3:
In Kubuntu 14.04, this does not work, if you set GRUB_TIMEOUT= 0
,
strangely, after applying this and rebooting,
the grub menu remains visible for 10s.
The reason for this is that in another grub script there is a piece of code that sets grub_timeout to 10 if it has the value of 0.
So this is how i got it to work:
make a copy of both grub
and 30_osprober
files !!!
When something goes wrong, you can put the original files back
In /etc/default/grub
GRUB_DEFAULT=4 #set this value to the OS you want to boot
GRUB_HIDDEN_TIMEOUT=0
GRUB_TIMEOUT=0
in /etc/grub.d/30_os-prober
,
there is a piece of code that sets grub timeout to 10s if it is set to zero in /etc/default/grub
, I don't know why the devs put it there, but it prevents hiding the grub menu.
set timeout_style=menu
if [ "\${timeout}" = 0 ]; then
set timeout=10 # I changed this from 10 to 0
After these changes, run sudo update-grub
to generate the new grub boot sequence.
I document all my linux fixes/mods on https://sites.google.com/site/marcshomesite/Home/linux-tuning