74

I stopped dual booting and I don't want to have to choose the OS any more. I want to boot into Ubuntu 12.04 directly without seeing the GRUB menu.

How can I achieve that?

Zanna
  • 70,465
Alex Poulos
  • 1,544
  • 7
  • 19
  • 30
  • If you stopped dual booting, probably you have stopped using the other OS. Why cant you remove the other OS so that ubuntu can boot normally. – karthick87 Mar 08 '12 at 08:37
  • Duplicate of (either) http://askubuntu.com/questions/124074/dual-boot-default-question-w7-ubuntu or http://askubuntu.com/questions/52963/how-do-i-set-windows-to-boot-as-the-default-in-the-boot-loader – david6 Jun 13 '12 at 07:57
  • if any of these answers "answered" your question please accept one of them :) – blade19899 Jul 11 '12 at 16:04
  • @david6: I don't see how either of those are duplicates of this question. I think this is about hiding the grub menu during the timeout. – oKtosiTe Sep 20 '12 at 09:36
  • Sorry, the second link was supposed to be: http://askubuntu.com/questions/66070/how-to-set-windows-bootloader-as-default-bootloader This includes how to: *Hide the Grub2 menu, and use the default menu option* – david6 Sep 20 '12 at 09:49
  • It seems like there's a bug in 30_os-prober script that overrides the value of timeout and timeout_style variable. Has anybody reported it??? – opensas Dec 04 '14 at 03:59
  • Aside from all the recipes you'll find, sometimes you need to get down to brass tacks. It is far from the first thing a search engine returns when searching for this kind of thing, so here's the documentation: https://www.gnu.org/software/grub/manual/html_node/Simple-configuration.html – lmat - Reinstate Monica Apr 14 '15 at 13:21
  • For a solution involving the use of the software Boot Repair, see: https://askubuntu.com/a/1119833/818816 – Bruno A Chrisostomo Feb 20 '19 at 12:52

22 Answers22

45

You can just change grub settings.

type in terminal

sudo -H gedit /etc/default/grub

you need to change this

Change GRUB_HIDDEN_TIMEOUT_QUIET=false to

GRUB_HIDDEN_TIMEOUT_QUIET=true

Save the file and exit

Type sudo update-grub

If you don't get the result you want, see this bug.

hingev
  • 6,596
38

I solved this problem by disabling the OS Prober. I did that because in /boot/grub/grub.cfg in the part generated by the template /etc/grub.d/30_os-prober, there was an override of "timeout" to 10 and "style" to menu.

Edit /etc/default/grub and add this line:

GRUB_DISABLE_OS_PROBER=true

Hope you find this useful!

BTW, my full /etc/default/grub is:

GRUB_DEFAULT=0
GRUB_TIMEOUT=0
GRUB_TIMEOUT_STYLE=hidden
GRUB_HIDDEN_TIMEOUT=0
GRUB_HIDDEN_TIMEOUT_QUIET=true
GRUB_DISTRIBUTOR= [...]
GRUB_DISABLE_OS_PROBER=true
GRUB_RECORDFAIL_TIMEOUT=0

Happy coding

Zanna
  • 70,465
  • 2
    that worked for me, but it made dissapear al the other boot options but the default one... – opensas Dec 04 '14 at 02:01
  • 1
    @opensas If the selection menu isn't displayed, how do you even know what boot options "appear" on it? If you want to disable the menu, why would you want non-default boot options? – Kyle Strand Feb 23 '16 at 21:48
  • if you leave out the 'GRUB_TIMEOUT_STYLE=hidden' part, then the countdown is visible, but nothing else, unless you interrupt it. That allows you to get to the menu and change boot settings, even while making it much less obvious. – stonecrusher Oct 04 '16 at 05:45
  • If one wants to be able see the boot menu after holding Shift key, GRUB_TIMEOUT must be set to greater then zero (say, GRUB_TIMEOUT=5). Otherwise, other boot options (say, Windows) can not be activated if needed. – user3804598 Jan 02 '17 at 21:11
  • On Ubuntu 18.04 LTS, GRUB_RECORDFAIL_TIMEOUT=0 is the only change to /etc/default/grub that eliminates the 30 second timeout (and the GRUB bootloader menu altogether), which seems to be a bug: https://bugs.launchpad.net/ubuntu/+source/grub2/+bug/1814403/comments/4 . Also, sudo update-grub must be executed for the edits to take effect, which is not mentioned in the Answer. Note that setting this value to 0 is not advised (see above-cited link) unless the machine is a development VM or similar. – Ben Johnson Oct 10 '19 at 13:46
  • You don't need to disable the OS Prober. See https://askubuntu.com/a/1197788/585408 – Resigned June 2023 Dec 22 '19 at 01:48
12

I tried all those tips they didnt work, ended up reducing the timeout time to zero as follows:

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=""
SirCharlo
  • 39,486
10

You need to edit the file at /etc/default/grub to prevent showing the grub menu.

By default, the entries in that files look like this.

GRUB_DEFAULT=0
#GRUB_HIDDEN_TIMEOUT=0
GRUB_HIDDEN_TIMEOUT_QUIET=false
GRUB_TIMEOUT=10
GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"
GRUB_CMDLINE_LINUX=""
  • Remove the # mark from second line, and
  • Change the line GRUB_HIDDEN_TIMEOUT_QUIET=false to GRUB_HIDDEN_TIMEOUT_QUIET=true.

After changes, the required portion of the file will look like this


GRUB_DEFAULT=0
GRUB_HIDDEN_TIMEOUT=0
GRUB_HIDDEN_TIMEOUT_QUIET=true
GRUB_TIMEOUT=10
GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"
GRUB_CMDLINE_LINUX=""
  • Then run sudo update-grub command in the terminal, and reboot to see the result.
Anwar
  • 76,649
  • 3
    I had this configuration but still the grub menu appears. –  Aug 09 '13 at 07:51
  • 1
    With this setting update-grub returns, 'Warning: Setting GRUB_TIMEOUT to a non-zero value when GRUB_HIDDEN_TIMEOUT is set is no longer supported' and I still get a 10 second countdown while showing the grub menu. Setting GRUB_TIMEOUT to 0 returns the same results also. – zorkerz Mar 12 '16 at 14:55
  • @zorkerz which version of ubuntu are you using? – Anwar Mar 12 '16 at 17:11
  • Xenial Xerus but had the same behavior on 15.10 – zorkerz Mar 13 '16 at 17:39
  • Note that this answer was written in 2012 and is out of date. – Flimm Oct 28 '20 at 11:58
7

I had the same problem and none of the tips here worked! The only way was to change /boot/grub/grub.cfg manualy. At some point of this file he makes the timeout goes to 10! So, just comment those lines

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

But, you can never do update-grub again, otherwise it will turn back to the same file, and timeout is going to 10 again! Save the file (in vi you will need to force it even if you are su!). Restart the computer and it will work just fine!

user3680055
  • 71
  • 1
  • 2
  • Interesting, why not if [ "${timeout}" = 10 ]; then set timeout=0 fi ? Or simply remove the if statement entirely and just leave set timeout=0? – Elder Geek Jun 25 '14 at 03:22
  • This is put there from a template which can be disabled (the OS prober, as mentioned in Agustin's answer). You don't need to manually edit grub.cfg. – Neil Traft Nov 22 '14 at 03:49
  • this worked for me in 14.04 – Kalamalka Kid May 27 '16 at 23:56
  • -1. Any answer involving directly editing grub.cfg is just wrong. You must always reinstall grub when updating it, especially when upstream makes breaking changes, or you risk an unbootable system. – éclairevoyant Jun 26 '23 at 13:28
4

I've found a simple solution to the problem.

  echo "
  set timeout_style=hidden
  set timeout=2" | sudo tee --append /etc/grub.d/40_custom 

And update grub. It will overwrite timeout settings in grub.cfg, so it doesn't matter what you have in /etc/default/grub. So I have hidden menu that can be invoked by shift for 2 sec.

  • This approach worked for me (grub 2.02~beta3-4ubuntu7 installed by Ubuntu 17.10) when none of the other solutions proposed on this page did (it's really bad luck that I tested this last :/). Thanks! – pchaigno Jul 16 '18 at 08:33
3

if you want to remove a boot entry just type in:

sudo update-grub

If that doesn't work, install the startup manager, like so:

sudo apt-get install startupmanager


with startup-manager you can

  1. choose with entry to boot in,
  2. choose the resolution and, how long to wait before booting,
  3. you can also choose 0 for automatic booting the default boot-entry
blade19899
  • 26,704
3

Ideally, we could just put

GRUB_TIMEOUT_STYLE=hidden
GRUB_TIMEOUT=0

into /etc/default/grub and be done with it. Unfortunately, at least on Manjaro, the file /etc/grub.d/30_os-prober overrides these settings. We could disable that file, but here's a better solution: create /etc/grub.d/99_quiet with these contents:

#!/bin/sh

cat <<EOF
set timeout_style=hidden
set timeout=0
EOF

(With this file, we don't even need to modify /etc/default/grub at all.) Make it executable and run sudo update-grub (or sudo grub-mkconfig -o /boot/grub/grub.cfg if on Arch).

Reboot and GRUB will not display the menu or introduce any delay during boot. But, you can still get the menu if you hold down Shift after the hardware has turned on but before GRUB has started.

To understand what is happening here we must understand how GRUB configuration works. There is a /boot/grub/grub.cfg file in a special DSL that is read by GRUB during boot. This can be written manually but it is preferred to generate it using update-grub (i.e. grub-mkconfig). That command uses /etc/default/grub and /etc/grub.d to generate the grub.cfg. The /etc/default/grub is sourced first, to set the configuration parameters for update-grub to generate the file. Then, each file in /etc/grub.d that is executable is executed, and its output is concatenated to the end of the grub.cfg.

For some docs, see here, but see also the actual shell scripts in /etc/grub.d and the resulting GRUB configuration /boot/grub/grub.cfg.

  • This did not work for me with Debian Bullseye (alpha). – Michael Herrmann Feb 11 '21 at 06:50
  • @MichaelHerrmann Unfortunately that doesn't surprise me, different distros may have different default config files with different behavior. I think you'll have to investigate more thoroughly using the info in the last two paragraphs of the answer. Maybe you can update it with a note for your distro! – Resigned June 2023 Feb 14 '21 at 17:57
  • That worked for me on Ubuntu Mate 22.04, apart from the Shift part, even if I hold Shift just after boot grub doesn't appear (but TBH I don't bother much, I just wanted it to go away). THANKS! – babis21 May 13 '22 at 20:51
3

Add the following line to /etc/default/grub:

GRUB_FORCE_HIDDEN_MENU="true"
Peque
  • 1,143
3

for all of you that have word splash in cmd line anything but hardcoding 0 for timeout won't work,,

GRUB_DEFAULT=0
GRUB_HIDDEN_TIMEOUT=0
GRUB_HIDDEN_TIMEOUT_QUIET=true
GRUB_TIMEOUT=10
GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"
GRUB_CMDLINE_LINUX=""

Try removing word splash from second last line, update and reboot,, voila, no menu :)

hth, krex

3

Like Agustin, I found that my issue was with the OS Prober. Doing one step better than his solution, I found this gist that will let you have your OSes but still hide the menu. You just need to download those two files, put them into /etc/grub.d, and give them the same permissions as the other templates in that directory.

If you ever want to access your non-default OS, just hold down shift while booting up. That will show the menu.

2

For Ubuntu 20.04

Run the following command in terminal. It will create a custom configuration file for grub specifying the boot delay (setting timeout=0 removed the grub screen)

echo "set timeout_style=hidden
set timeout=0" | sudo tee boot/grub/custom.cfg

There is a nice explanation for this here.

Daniel
  • 163
2

I've been seeing a lot of people saying that the suggested answers don't work for them. I tried several options and this one worked for me:

Edit /etc/grub.d/00_header, and find:

if [ "\${recordfail}" = 1 ]; then
  set timeout=-1

Change it to...

if [ "\${recordfail}" = 1 ]; then
  set timeout=10

And run update-grub.

2

this took me a while but it payed off it was a mix of my own digging and answers above first make sure your /etc/default/grub and /usr/grub/default/grub are the same. then run gksu gedit /etc/grub.d/30_os-prober near the top are the two lines we want but to find them search for styke and change that line to hidden then search for a timeout line it should be like if timeout = 0 set to 10 delete that part from the if to end of file make sure you delete the end of file or your screwed and your grub config should log something like this this is mine just for example:

sets default boot to windows 8.1 pro

GRUB_DEFAULT="Windows 8 (loader) (on /dev/sda1)"

sets a five second window to hit shift so i can boot into Ubuntu

GRUB_HIDDEN_TIMEOUT=5
GRUB_HIDDEN_TIMEOUT_QUIET=true

main fix for error just in case

GRUB_TIMEOUT=0

sets style to hidden

GRUB_TIMEOUT_STYLE=hidden

default Ubuntu stuff

GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"
GRUB_CMDLINE_LINUX=""
αғsнιη
  • 35,660
Darian
  • 21
1
  • Configure grub via sudo nano /etc/default/grub
  • Type end of the file:
GRUB_HIDDEN_TIMEOUT=0
GRUB_TIMEOUT=0
  • Save changes CTRL + S
  • Exit CTRL + X
  • Update grub menu sudo update-grub
yEmreAk.com
  • 1,289
1

As of ubuntu 22.10 i recommend this:

edit the file /etc/default/grub:

sudo nano /etc/default/grub

Make sure you have this lines:

GRUB_TIMEOUT=0
GRUB_RECORDFAIL_TIMEOUT=0

Save and exit run updater:

sudo update-grub
0

If setting GRUB_TIMEOUT= to zero in /etc/default/grub does not work, somewhere in /boot/grub/grub.cfg (the actual grub script) the timeout is getting changed. In the file which causes this, comment that line and run update-grub. This way GRUB_TIMEOUT= applies again and your change will persist resourcing grub.cfg.

How to:
Start off by by trial and error: search for set timeout in /boot/grub/grub.cfg and change the timeout, reboot (do not run update-grub) and check if that changed the grub menu. If not, undo last edit and move to the next.

After you found the miscreant line in grub.cfg you need to look where it came from. Look for the ### BEGIN & ### END (/boot/grub/grub.cfg is generated by update-grub and sources files in /etc/grub.d/). In the vicious file, eg. /etc/grub.d/00_header, comment the corresponding line that sets the timeout and run update-grub.
Now GRUB_TIMEOUT=0 will skip the menu

josh
  • 1
0

I have a dell XPS plus with Ubuntu 22.04. Bit similar to one of the answers above, none of the top answers worked for me. Following a thread here, I had to change the /etc/grub.d/00_header file. The logic always flows through the efi branch and any other changes in other files does not work. I had to change the timeout value from 30 to 0. Then do a sudo update-grub.

if [ \$grub_platform = efi ]; then
  set timeout=${GRUB_RECORDFAIL_TIMEOUT:-30}
  if [ x\$feature_timeout_style = xy ] ; then
    set timeout_style=menu
  fi
fi
Isuru
  • 179
0

I managed to work it here is my grub stuff

GRUB_DEFAULT=0
GRUB_TIMEOUT_STYLE=hidden
GRUB_HIDDEN_TIMEOUT=0   
GRUB_HIDDEN_TIMEOUT_QUIET=true
GRUB_TIMEOUT=0
GRUB_DISTRIBUTOR=`lsb_release -d -s 2> /dev/null || echo Debian`
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"
GRUB_CMDLINE_LINUX=""
GRUB_SAVEDEFAULT=true
GRUB_DEFAULT=saved
GRUB_DISABLE_OS_PROBER=true
GRUB_RECORDFAIL_TIMEOUT=0
GRUB_ENABLE_CRYPTODISK=y
0

Use this command to edit the file sudo -H gedit /etc/default/grub

In my case, my /etc/default/grub file was in this state

GRUB_DEFAULT=0
GRUB_TIMEOUT_STYLE=hidden
GRUB_TIMEOUT=10
GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"
GRUB_CMDLINE_LINUX=""

First of all, I added the line GRUB_HIDDEN_TIMEOUT_QUIET=true to the file. But it was hiding the grub menu but still was taking 10s to start. Then, I changed GRUB_TIMEOUT value to 0 and it worked now.

Finally, the file looks like this:

GRUB_DEFAULT=0
GRUB_TIMEOUT_STYLE=hidden
GRUB_TIMEOUT=0
GRUB_HIDDEN_TIMEOUT_QUIET=true
GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"
GRUB_CMDLINE_LINUX=""

Don't forget to run this command sudo update-grub in the terminal every time you make a change and save it. Otherwise, your changes won't be applied.

0

Attempt this at your own risk and only as a last resort!

I tried editing /etc/default/grub and running sudo update-grub with no results.

Ended up editing /boot/grub/grub.cfg by hand, specifically,

...
### END /etc/grub.d/00_header ###

set timeout=0
saved_entry="Ubuntu"
save_env saved_entry

### BEGIN /etc/grub.d/05_debian_theme ###
...
Epigene
  • 101
  • 2
-1
GRUB_DEFAULT=0
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=""

# Set this if you hide grubmenu at boot! hidden-timeout has to be 0-10
# NOT recommend with dual-boot systems
# Type ESC/ENTER at boot to make grub-menu visible again! 
# in this case hidden-timeout has to be 3-10
GRUB_DISABLE_OS_PROBER=true

solves the problem! s.grub2 @ubuntuusers! ;-)

Also it's possible to make grub-menu visible again during booting!

IMPORTANT if you have a crash and want to boot an older (and stable) Kernel!

(Tested with Linux Mint 17.3 Rosa which is based on Ubuntu 14.04)

chalee
  • 7