21

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

Eric
  • 311

7 Answers7

29

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.

C2H5OH
  • 869
  • 1
    Thank you very much, this is exactly what I was looking for! – Avio Oct 17 '13 at 11:59
  • 1
    After making the change, also run update-grub to generate the updated /boot/grub/grub.cfg file – Colt Feb 25 '19 at 02:27
  • 1
    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 '19 at 12:14
  • @CameronTacklind Do you happen to have any source for that? @sniffski's answer didn't work for me probably because of $grub_platform = efi as mentioned here. So setting the GRUB_RECORDFAIL_TIMEOUT is a workaround in my case. That said I'd still want to avoid using the variable in an unintended way. – Carolus Dec 27 '19 at 09:07
  • @Carolus Imho, you should track down the reason the fail flag is getting set instead of just patching over it. – Cameron Tacklind Dec 27 '19 at 10:30
  • 1
    @CameronTacklind I made a separate question about this. – Carolus Dec 27 '19 at 11:13
7

Use:

grub-editenv create

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

Braiam
  • 67,791
  • 32
  • 179
  • 269
sniffski
  • 71
  • 1
  • 1
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

Suhaib
  • 4,110
  • 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 00: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 those out.

To skip the menu and show it only when 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 the timeout set by GRUB_TIMEOUT to expire. If ESC is pressed during that time, it will display the GRUB menu and wait for input.

Carolus
  • 587
Gayan Weerakutti
  • 3,770
  • 26
  • 38
  • 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

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.

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.

Pang
  • 373
lumbric
  • 3,994
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