Just installed Ubuntu 10.10 on my laptop dual-booting with Windows.  I wanted it to default to windows and allow me to choose when to boot into linux.  It used to be that you can just go to /boot/grub/menu.lst and edit the entry there.  With grub2 there are different files that you have to edit.

UPDATE 01/12/12:  The method below works fine, but as you install updates there will be new entries in the grub boot list and you will have to keep on modifying the GRUB_DEFAULT value to get it to boot into Windows.  A better way to accomplish this is to move Windows to the top of the list and leave the Grub Default at 0. A good tool to accomplish this is called Grub Customizer. Follow the instructions at this site and download the Grub Customizer app.  Once installed you can unselect items in your grub menu that you do not want to appear, and also click on the Windows entry (under “OS Prober” heading) and move it to the top of the list by clicking Ctl-U.  Since your Default is 0, and now Windows is at order number 0 in the Grub List it will default to that OS.  The only thing I’m not sure of, since I’ve installed all the updates already, is if an update will place the new list item on the top making you run this program again to place Windows at the top of the list.  Next update I install I will test this out and update this post. (I have tested it out on my system with no problems, but I take no responsibility if somehow your system gets screwed up)

To accomplish the same thing as editing menu.lst, first display your menu choices by running the following command:

$ cat boot/grub/grub.cfg|grep menuentry

which will give you a list like this:

menuentry ‘Ubuntu, with Linux 2.6.35-22-generic’ –class ubuntu –class gnu-linux –class gnu –class os {
menuentry ‘Ubuntu, with Linux 2.6.35-22-generic (recovery mode)’ –class ubuntu –class gnu-linux –class gnu –class os {
menuentry “Memory test (memtest86+)” {
menuentry “Memory test (memtest86+, serial console 115200)” {
menuentry “Windows 7 (loader) (on /dev/sda1)” {

The first entry above is “0”, so going by the menu above I would like to boot into “4” which is Microsoft windows. Go to /etc/default directory, and then edit the file “grub” with the command

$ sudo vi /etc/default/grub

# If you change this file, run ‘update-grub’ afterward to update
# /boot/grub/grub.cfg.

GRUB_DEFAULT=4
#GRUB_HIDDEN_TIMEOUT=0
GRUB_HIDDEN_TIMEOUT_QUIET=true
GRUB_TIMEOUT=10

After changing this file and rebooting multiple times and seeing no changes, I discovered (<cough> read the /etc/default/grub comments.. duh!!!) that you must now run the following command to update the grub.cfg file:

$sudo update-grub

that should be it. After running this command and rebooting it correctly defaulted to the 4th entry which was windows.

If you don’t know vi commands.  Just navigate down to the value you want to change and hit “r” and type “4” or whatever number you want to boot into by default.  Then when you’re done save it by typing the following “:wq”  That should do it. Or for a GUI editor use the command “$sudo gedit /etc/default/grub” for a wordpad/notepad type editor.

For more information on grub2 check here

To check what grub version you are running run. Anything equal to or above 1.96 is grub2

$grub-install -v

Advertisements