24

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
  • 341

7 Answers7

32

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
  • 909
7

Use:

grub-editenv create

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

Braiam
  • 69,112
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,171
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
  • 600
Gayan Weerakutti
  • 3,830
  • 1
  • 28
  • 39
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
  • 4,129
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