1

I want to disable the boot menu and still be able to start Ubuntu instead of Windows by holding a key down.

Is this possible?

7
  • Please edit your question to clarify what you mean by "with a key". thank you for helping us help you! – Elder Geek Jun 6 '15 at 19:29
  • Done. I have edited – Unknown Jun 6 '15 at 19:34
  • 1
    Could you not just set the time to like 2 seconds for the boot option menu and if no thing is pressed it starts windows as first choice? – magnusnn Jun 6 '15 at 19:36
  • I'm not the only who use this PC, because of this I want to start ubuntu manually and not with a start menu. – Unknown Jun 6 '15 at 19:43
  • This is unnecessary. Other people without an Ubuntu account will be unable to log in anyway provided you apply basic security concepts regarding your password. – Elder Geek Jun 6 '15 at 19:45
3

For your needs you have to edit the GRUB configuration:

/etc/default/grub from Terminal using sudo

sudo gedit /etc/default/grub

A fresh installation should look like this:

# This file is sourced by update-grub, and its variables are propagated
# to its children in /etc/grub.d/
GRUB_DEFAULT=0
#GRUB_HIDDEN_TIMEOUT=0
GRUB_HIDDEN_TIMEOUT_QUIET=true
GRUB_TIMEOUT="3"
GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"
GRUB_CMDLINE_LINUX=""

# Uncomment to disable graphical terminal (grub-pc only)
#GRUB_TERMINAL=console

# The resolution used on graphical terminal
# note that you can use only modes which your graphic card supports via VBE
# you can see them in real GRUB with the command `vbeinfo'
#GRUB_GFXMODE=640x480

# Uncomment if you don't want GRUB to pass "root=UUID=xxx" parameter to Linux
#GRUB_DISABLE_LINUX_UUID="true"

# Uncomment to disable generation of recovery mode menu entrys
## Bis GRUB 1.98
#GRUB_DISABLE_LINUX_RECOVERY="true"
## Ab GRUB 1.99
#GRUB_DISABLE_RECOVERY="true"

# Uncomment to get a beep at grub start
#GRUB_INIT_TUNE="480 440 1"

To automatically boot Windows, you have to change

GRUB_DEFAULT=0

to the number of the entry for Windows in GRUB. Keep in mind that the menu entries start at 0, not 1.

To disable the menu, you have to enable

#GRUB_HIDDEN_TIMEOUT=0

by removing the '#' and changing the value from '0' to '1' like this: GRUB_HIDDEN_TIMEOUT=1.

You also have to disable

GRUB_TIMEOUT="3"

by placing a '#' at the beginning of the line like this: #GRUB_TIMEOUT="3"

When you are done editing, save the file and then run the following command to apply the changes:

sudo update-grub

If you then want to boot into Ubuntu (or any other OS) you have to hold Shift while starting, then the GRUB-Menu will be displayed and you can select Ubuntu.

2

You can configure grub2 to do exactly what you want. You can configure grub2 by editing /etc/default/grub when running Ubuntu.

sudo  -i gedit /etc/default/grub

It will ask you for your password. This means that your system is trying to protect you from yourself. Make sure you know what you're doing. Don't take my word for it. Read the documentation. If you are at all unclear as to what you're doing, it's wise to create a backup with the default settings in tact (sudo cp /etc/default/grub /etc/default/grub.old) before editing the file.

Once you enter your password, gedit should open. Below is what I see when it opens up. You'll see something slightly different than this, as I don't dual boot:

# If you change this file, run 'update-grub' afterwards to update
# /boot/grub/grub.cfg.
# For full documentation of the options in this file, see:
#   info -f grub -n 'Simple configuration'

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

# Uncomment to enable BadRAM filtering, modify to suit your needs
# This works with Linux (no patch required) and with any kernel that obtains
# the memory map information from GRUB (GNU Mach, kernel of FreeBSD ...)
#GRUB_BADRAM="0x01234567,0xfefefefe,0x89abcdef,0xefefefef"

# Uncomment to disable graphical terminal (grub-pc only)
#GRUB_TERMINAL=console

# The resolution used on graphical terminal
# note that you can use only modes which your graphic card supports via VBE
# you can see them in real GRUB with the command `vbeinfo'
#GRUB_GFXMODE=640x480

# Uncomment if you don't want GRUB to pass "root=UUID=xxx" parameter to Linux
#GRUB_DISABLE_LINUX_UUID=true

# Uncomment to disable generation of recovery mode menu entries
#GRUB_DISABLE_RECOVERY="true"

# Uncomment to get a beep at grub start
#GRUB_INIT_TUNE="480 440 1"

What you want is (1) make grub boot Windows 7 by default and (2) make the grub menu invisible unless you press a key. (1) can be achieved by changing the value of DEFAULT_GRUB= and (2) can be achieved by changing the value of GRUB_HIDDEN_TIMEOUT=.

  1. There are several ways to go about this. You can set DEFAULT_GRUB=#, where # is the entry number of Windows 7 in the grub menu. The entries start at 0, so if Windows 7 is the third menu option, you would set DEFAULT_GRUB=2. You can also set DEFAULT_GRUB="xxxx", where "xxxx" is the name of your Windows 7 install as it appears in the grub menu. Make sure to include the quotation marks (") if you choose the latter option.

Save the file and exit gedit.

  1. You're going to want to uncomment the GRUB_HIDDEN_TIMEOUT and comment out the GRUB_TIMEOUT line. We also need to set the hidden timeout value to 1.

Run the following command to make the changes:

sudo sed -i 's/^\#GRUB_HIDDEN_TIMEOUT/GRUB_HIDDEN_TIMEOUT/g;s/^GRUB_TIMEOUT/#GRUB_TIMEOUT/g;s/^GRUB_HIDDEN_TIMEOUT=.*$/GRUB_HIDDEN_TIMEOUT=1/g'

Finally, run the following command to apply the changes to grub and you'll be all set:

sudo update-grub

When you reboot your computer, it should boot Windows 7 without showing the grub menu. Simply press the shift key during the boot process and the grub menu will appear.

2
  • how shift? is that the default? pressing shift breaks the timeout? – Saravanabalagi Ramachandran Mar 27 '17 at 17:25
  • @SaravanabalagiRamachandran Shift will work if you set the hidden timeout to 1 and comment out the GRUB_TIMEOUT line. – mchid Oct 4 '19 at 20:29

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