Modifying the Linux Grub boot loader's optionsPosted in Linux/Unix/BSD -
One of my Linux CD Mall customers emailed me the other day with a Linux annoyance: "The computer always booted into Linux by default if I wasn't quick enough to stop it. Most annoying. I would have preferred the computer to wait until I told it where to boot but could not find a way of doing that. All of the Linux distros that I tried just take over without being asked." This post looks at how you can change the grub boot loader's settings to solve this issue using a text editor. And I agree with him, it is annoying how the boot loader is often set up by default to boot into Linux too quickly.
The screenshots below come from Fedora 8, and show the problem in action.
This first screenshot shows when the computer first boots up. There's a nice screen showing that you are booting into Fedora 8 and you have 5 seconds to hit any key to decide to select a different boot option. If you are not paying attention then the 5 seconds might elapse and it will boot into Linux without you getting the choice. You might want to always select which operating system to load, or you might want it to load Windows by default, or a different operating system also installed on your computer.
The second screenshot shows the boot menu after you have pressed any key. In this example the boot menu offers the choice between Fedora 8 and Windows. By default Fedora 8 is selected but you can choose to move the arrow keys up and down and then hit the enter key when you are ready.
If you want to change this behaviour then you need to edit the Grub boot loader's menu configuration file. This is usually located at /boot/grub/menu.lst or /boot/grub/grub.conf but may vary depending on the Linux distribution.
Open up the file using a text editor, either running the command as root or using sudo. In the example below I'm using "nano".
sudo nano -w /boot/grub/menu.lst
An example Grub menu file might look like this:
# grub.conf generated by anaconda # # Note that you do not have to rerun grub after making changes to this file # NOTICE: You do not have a /boot partition. This means that # all kernel and initrd paths are relative to /, eg. # root (hd0,2) # kernel /boot/vmlinuz-version ro root=/dev/sda3 # initrd /boot/initrd-version.img #boot=/dev/sda default=0 timeout=5 splashimage=(hd0,2)/boot/grub/splash.xpm.gz hiddenmenu title Fedora (126.96.36.199-85.fc8) root (hd0,2) kernel /boot/vmlinuz-188.8.131.52-85.fc8 ro root=LABEL=/ rhgb quiet acpi=off initrd /boot/initrd-184.108.40.206-85.fc8.img title Windows rootnoverify (hd0,0) chainloader +1
GRUB's hiddenmenu option
The "hiddenmenu" option hides the boot menu so you need to press a key to get to it, instead showing the example splash screen in the first screenshot above. Fedora 8 by default only allows you 5 seconds before booting into the default option so if you are not paying attention you might miss it and have to reboot before being able to make your selection.
To stop this behaviour and go straight to the boot menu instead of the hidden screen change it to this:
This comments it out and means the boot menu will no longer be hidden, allowing you to always see the menu list when booting up. If you want to change back to a hidden menu at some later stage you can uncomment it by removing the # character.
GRUB's timeout option
The "timeout" option specifies how long in seconds the hidden menu or regular menu list should wait before automatically booting into the default option. On Fedora 8 the default is 5 seconds. You can either make it a much longer time, such as 30 or 60 seconds, or disable it entirely and make GRUB always wait until you specifically make a selection.
To change the timeout to e.g. 30 seconds do this:
To disable the automatic boot option, "comment" out the line as per the hiddenmenu option above:
You can then re-enable it later by removing the # symbol.
GRUB's default option
The final thing you might want to do is to change the operating system that is selected by default. Whether you choose to have auto boot enabled or not, the default option will always be selected by default. That way all you have to do to boot into it is hit the enter key (or wait, if you have a timeout set) and only need to use the arrow keys to select a non-default option.
The default=X setting specifies which operating system to boot into by default. The options are number starting from 0 in order of the file. In the example menu list above 0 would be Fedora and 1 Windows. To change the default operating system to Windows in the above example you would change the default line to be like so:
GRUB allows you to specify which operating systems can be booted to when the computer first starts, but the default settings of many Linux distributions these days hide the GRUB menu and/or give you little time to make another choice. It is simple to change these settings as documented above.