18

I am running Ubuntu 12.04.

I cannot for the life of me get the grub menu (with options) to go away.

I would like it to auto-boot into the first option. I've edited /etc/default/grub so that it looks like the following:

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

After this, I ran sudo update-grub. Then I realized that I had grub 2, so I ran sudo update-grub2 (both make it look like they create the grub.cfg file successfully.

I restart my computer and it goes back to the grub menu and just sits there until I make a choice. This is not desirable if the power goes out... :-)

I also tried reinstalling grub using sudo grub-install /dev/sda - also unsuccessful

  • Do you by any chance have another partition that you installed Ubuntu to after setting up the current partition that you now wish to boot into automatically? – fabricator4 Oct 18 '12 at 2:48
  • I'm not sure what you mean, I'm kind of new to linux. I did install over a previous Ubuntu installation, but I did not upgrade. Clean install. I may have mucked something up partition-wise... that's possible, any ideas on fixing it? – Eric Oct 18 '12 at 4:20
  • sudo update-grub and sudo update-grub2 runs the same command. So, don't worry about that part. – saji89 Oct 18 '12 at 6:01
  • Please you post the output of cat /boot/grub/grub.cfg via pastebin and share the link here. This is to see the actual grub.cfg generated. – saji89 Oct 18 '12 at 6:03
  • Here's the pastebin: pastebin.com/xxe2rLhg of grub.cfg. Thanks for all your help! – Eric Oct 18 '12 at 13:39
22

As other answers point out, you may be a victim of the recordfail situation. Editing /boot/grub/grub.cfg manually should be out of the question as is automatically generated. Another suggestion seen around is to edit the /etc/grub.d/00_header but then it could prompt for user intervention on updates.

The easiest solution is to define the undocumented GRUB_RECORDFAIL_TIMEOUT variable in /etc/default/grub. For example:

GRUB_HIDDEN_TIMEOUT=0
GRUB_HIDDEN_TIMEOUT_QUIET=true
GRUB_TIMEOUT=5
GRUB_RECORDFAIL_TIMEOUT=$GRUB_TIMEOUT

Edit

See this answer for more details.

  • Thank you very much, this is exactly what I was looking for! – Avio Oct 17 '13 at 11:59
  • After making the change, also run update-grub to generate the updated /boot/grub/grub.cfg file – Colt Feb 25 at 2:27
  • Don't kill the functionality of recordfail! You want a longer timeout if there was a failure booting. To manually clear, all you need is @sniffski's answer: grub-editenv create. However, there might be some other reason recordfail is getting set... – Cameron Tacklind Nov 29 at 12:14
6

Use:

grub-editenv create

This will clear grub environment file and should boot clearly the next time.

  • Thank you very much for sharing. This worked via SSH which made my day for a stuck on grub headless server. – Geppettvs D'Constanzo Jun 9 '16 at 16:31
  • grub-editenv - unset recordfail works as well and doesn't affect other envs that might be set – Cameron Tacklind Nov 29 at 12:17
2

change the GRUB_TIMEOUT=10 to zero

This is my Configuration file:

GRUB_DEFAULT="Ubuntu, with Linux 3.2.0-30-generic-pae"
#GRUB_HIDDEN_TIMEOUT=10
#GRUB_HIDDEN_TIMEOUT_QUIET=true
GRUB_TIMEOUT=1
GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`
GRUB_CMDLINE_LINUX_DEFAULT=""
GRUB_CMDLINE_LINUX=""

First, write the name of the OS that you want to boot to directly. Mine is Ubuntu. So you will write it as in the GRUB_DEFAULT="Ubuntu, with Linux x.x.x-xx-generic-pae"

then I used 1 second in the GRUB_TIMEOUT= to give me 1 second before selecting the default OS (if I need to boot to another OS for example Xubuntu)

as for GRUB_CMDLINE_LINUX_DEFAULT="" if you remove quite splash it will show you texts instead of the Ubuntu logo during the booting process (I like it this way :P )


There is another solution:

There is a program called boot-repair which helps in configuring with a GUI.

enter image description here

enter image description here

as you can see from the image. there is a box called Unhide boot menu. Just uncheck the box and press appy. You can access this by clicking on the advanced options arrow.

to install boot repair

sudo add-apt-repository ppa:yannubuntu/boot-repair

sudo apt-get update

sudo apt-get install -y boot-repair

and then run boot-reapir either from the terminal or from the dash.


3rd solution:

ou can use an easy to use GUI app called grub-customizer to make your life a little easy. As the name suggests, you can do much more than just reordering Grub menu entries with it.

You can install it by:

sudo add-apt-repository ppa:danielrichter2007/grub-customizer
sudo apt-get update
sudo apt-get install grub-customizer

enter image description here

as you can see from the menu there is show menu option. Unhceck and see if it works

  • No change. :-/ I thought GRUB_DEFAULT was supposed to be a numeric # according to the list in the menu? Changing GRUB_TIMEOUT to 0 didn't help. – Eric Oct 18 '12 at 13:28
  • @Eric you can use 2 ways: if you know the place of your OS in the grub list you can use a number. But for me I have 4 Linux distros and 1 Windows plus the memTest and the recovery. So its hard for me to memorize their places :) just to make sure(I know you may have done it but just to make sure :P ). Did you run the grub-update after changing the values ? – Suhaib Oct 18 '12 at 20:20
  • I did run grub-update after changing the values. :-/ – Eric Oct 18 '12 at 22:38
  • I installed and used the boot-repair app you provided, it works on the first reboot. After that, the GRUB menu is back and it sits there until I press a key. Thank you for all your help, I really appreciate it. Not sure where to go from here... – Eric Oct 19 '12 at 0:23
  • @Eric ok I found a 3rd solution check it – Suhaib Oct 21 '12 at 20:25
2

GRUB_HIDDEN_TIMEOUT and GRUB_HIDDEN_TIMEOUT_QUIET options are deprecated. So comment out those.

To skip the menu and show it when only holding ESC, add:

GRUB_TIMEOUT_STYLE='countdown'
GRUB_TIMEOUT=1

Sample /etc/default/grub

GRUB_DEFAULT=0
#GRUB_HIDDEN_TIMEOUT=0
#GRUB_HIDDEN_TIMEOUT_QUIET=true
GRUB_TIMEOUT=1
GRUB_TIMEOUT_STYLE=countdown
GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`
GRUB_CMDLINE_LINUX_DEFAULT=""
GRUB_CMDLINE_LINUX=""

'GRUB_TIMEOUT_STYLE': If this option is set to 'countdown' or 'hidden', then, before displaying the menu, GRUB will wait for the timeout set by 'GRUB_TIMEOUT' to expire. If ESC is pressed during that time, it will display the menu and wait for input.

  • it should, but all it does is shows the standard menu for 1 second. At least on a brand new 16.04 – frnhr Oct 22 '17 at 20:11
1

I could solve that issue by adding the following line to /etc/default/grub

GRUB_DISABLE_OS_PROBER=true

...and then running sudo update-grub.

Explanation: The file /boot/grub/grub.cfg is generated by running update-grub using the files in /etc/grub.d and /etc/default/grub. Therefore you should not edit grub.cfg, but it can be helpful to find out why the timeout is set. Search for lines starting with set timeout= and then search for the next line starting with ### END /etc/grub.d/ .... This might give you hints which script sets the timeout. In my case the os-prober script was responsible for the timeout. It turns out that there is a 10s hardcoded timeout in /etc/grup.d/30_os-prober which is not set by GRUB_TIMEOUT. You can either disable os-prober by GRUB_DISABLE_OS_PROBER=true or edit /etc/grup.d/30_os-prober or use GRUB_OS_PROBER_SKIP_LIST to skip some of your harddisk partitions (30_os-prober is used when another OS is found somewhere). See this Q&A for details. As others pointed out another reason might be the recordfail, in this case set GRUB_RECORDFAIL_TIMEOUT=$GRUB_TIMEOUT.

0

I had the problem that the grub menu appeared always after I used the AUFS (unionfs) to put the root filesystem readonly. I had phisically to hit the enter key at the server after every boot. I followed the instructions here : disable grub 2 menu. Since, I had no problems at all.

Edit the /boot/grub/grub.cfg and change:

if [ ${recordfail} = 1 ]; then
  set timeout=-1
else
  set timeout=10
fi

To

if [ ${recordfail} = 1 ]; then
  set timeout=1
else
  set timeout=10
fi
  • The before and after in your solution are exactly the same. – RawwrBag Dec 18 '14 at 1:38
  • set timeout=-1 is not the same as set timeout=1. The former is "wait forever", and the latter is "wait for one second". – Jeff McJunkin Jul 22 '15 at 18:36
0

My Ubuntu had always a timeout of 30 seconds either I would have set a value or not. Here after is how I have found out that recordfail was the missing value.

1. Verify the actual grub script /boot/grub/grub.cfg

IMHO, the best way to verify what Grub will do, is to open /boot/grub/grub.cfg. It is the script automatically generated by grub-mkconfig using templates from /etc/grub.d and settings from /etc/default/grub.

Around the line 109, you will see see something like:

108 if [ "${recordfail}" = 1 ] ; then
109   set timeout=30 # Note here this value
110 else
111   if [ x$feature_timeout_style = xy ] ; then
112     set timeout_style=hidden
113     set timeout=3
114   # Fallback hidden-timeout code in case the timeout_style feature is
115   # unavailable.
116   elif sleep --interruptible 3 ; then
117     set timeout=0
118   fi
119 fi

In my case with the help of that generated script, I could find out that the recordfail variable was unset.

2. If the recordfail variable is unset, set it

Open /etc/default/grub in your favourite text editor (e.g. vim) and then set the variable GRUB_RECORDFAIL_TIMEOUT to a given value, for example 5 seconds.

Your config file should look like:

GRUB_DEFAULT=0
GRUB_TIMEOUT=3
GRUB_TIMEOUT_STYLE=hidden
GRUB_HIDDEN_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=""
GRUB_RECORDFAIL_TIMEOUT=5

3. Update the configuration to run with update-grub

Last step, update the configuration to run with update-grub. For now on, GRUB2 will use the set timeout. This command will regenerate the /boot/grub.cfg file.

4. Verify the generated script result

Again, open /boot/grub.cfg and check the result around the line 109:

108 if [ "${recordfail}" = 1 ] ; then
109   set timeout=5 # Note here this value
110 else
111   if [ x$feature_timeout_style = xy ] ; then
112     set timeout_style=hidden
113     set timeout=3
114   # Fallback hidden-timeout code in case the timeout_style feature is
115   # unavailable.
116   elif sleep --interruptible 3 ; then
117     set timeout=0
118   fi
119 fi

Note that the value at line 109 is now 5 instead of 30 as before.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.