3 Ways Setting XP/Vista/Windows 7 as default bootup OS In Grub 2

This post was written by admin on November 19, 2009
Posted Under: General

This tutorial shows how to set default boot up OS in Grub 2 in 3 ways.And in my opinion the third one should be the best one,also the easiest one.
Following use XP as example.
Method 1:
Edit /boot/grub/grub.cfg and change XP to the first entry in grub 2.
By default this is read-only file,so change its permission in terminal(Applications/Accessories/Terminal):

sudo chmod 755 /boot/grub/grub.cfg

Then open this file:

sudo gedit /boot/grub/grub.cfg

Cut this section:

### BEGIN /etc/grub.d/30_os-prober ###
menuentry "Microsoft Windows XP Professional (on /dev/sda1)" {
	insmod ntfs
	set root=(hd0,1)
	search --no-floppy --fs-uuid --set 48142b45142b34fa
	drivemap -s (hd0) ${root}
	chainloader +1
}
### END /etc/grub.d/30_os-prober ###

Paste it between following two sections:

### BEGIN /etc/grub.d/05_debian_theme ###
set menu_color_normal=cyan/blue
set menu_color_highlight=white/blue
### END /etc/grub.d/05_debian_theme ###

### BEGIN /etc/grub.d/10_linux ###
menuentry “Ubuntu GNU/Linux, with Linux 2.6.31-14-generic” {
insmod ext2
set root=(hd0,6)
search –no-floppy –fs-uuid –set ff848303-508a-46d6-b275-0c263f7b8938

Close and save this file.
Note:If you run update-grub for some reasons,all things you do will back.You need to do again to set this default OS.
Mathod 2:
Count in /boot/grub/grub.cfg(start number 0),and in my case XP is 4.
grub2_default
So edit /etc/default/grub

sudo gedit /etc/default/grub

change Grub_default=0 into Grub_default=4

Note:This method won’t change grub menu order.However,when you upgrade kernel,the previous number will change and you need to set this again.
Method 3:edit /etc/grub.d/30_os-prober
/etc/grub.d/30_os-prober could be found in following section in /boot/grub/grub.cfg

### BEGIN /etc/grub.d/30_os-prober ###
menuentry "Microsoft Windows XP Professional (on /dev/sda1)" {
	insmod ntfs
	set root=(hd0,1)
	search --no-floppy --fs-uuid --set 48142b45142b34fa
	drivemap -s (hd0) ${root}
	chainloader +1
}
### END /etc/grub.d/30_os-prober ###

First,make a backup:

cd /etc/grub.d
sudo cp 30_os-prober 30_os-prober_backup

Then,change “30″ in filename to the number bewteen “5″ and “10″ (without 5 and 10).For instance:

sudo mv 30_os-prober 08_os-prober
sudo update-grub

Related posts:

  1. How to restore Grub 2 after reinstalling Windows XP/Vista/Win7
  2. Set Windows as Default OS in Grub
  3. Grub missed after reinstall Windows,or Grub error17 after delete Ubuntu partition
  4. Add Windows into grub menu after install Ubuntu
  5. Manually adding/removing entries to Grub 2 Menu

    Tags:

    Reader Comments

    In order to make it work with the third method, this command “sudo mv 30_os-prober 8_os-prober” should be
    “sudo mv 30_os-prober 08_os-prober”, the name of the new file should be 08_os-prober.

    [Reply]

    admin Reply:

    Oh,thanks Chris! I’ll has this update!

    [Reply]

    #1 
    Written By Chris on December 18th, 2009 @ 12:37 am

    but still, the most natural way to complete the task would be setting

    GRUB_DEFAULT=”xxxx”

    where “xxxx” is an exact menu entry. In this case, location in the menu will not matter.
    Example:

    GRUB_DEFAULT=”Windows 7 (loader) on /dev/sda1″

    see
    http://ubuntuforums.org/showthread.php?t=1195275
    for more

    [Reply]

    ragnar Reply:

    SET GRUB_DEFAULT=”Windows 7 (loader) on /dev/sda1″

    IN WHICH FILE !!!!!

    Why most natural ???

    Moreover, I found something called startupmanager to install with synaptic.

    Is this not compatible with 9.1 ?

    [Reply]

    #2 
    Written By v7 on January 19th, 2010 @ 8:05 am

    Best way is this !!

    Login as “root” or get access to root-group to edit files…

    Alternative
    if you don’t get added yourself as root user
    - Use Terminal (Applications/Accessories/Terminal)
    and type this parameter to get access edit file:
    sudo chmod 755 /etc/default/grub

    1)- Open this file in gedit-text editor (we start edit this file !!):
    sudo gedit /etc/default/grub

    2)- Open the other file where we can look our boot-os-names (we not edit this file !!):
    sudo gedit /boot/grub/grub.cfg

    3)- Read /boot/grub/grub.cfg bottom of list and look those:
    menuentry ” ”

    - You find windwos os boot name like windows 7:
    menuentry “Windows 7 (loader) (on /dev/sda1)”

    - Copy text with “quotes”:
    “Windows 7 (loader) (on /dev/sda1)”

    4)- Now go edit file /etc/default/grub line 4:
    change GRUB_DEFAULT=0 to GRUB_DEFAULT=”Windows 7 (loader) (on /dev/sda1)”

    - Save file

    5)- Finally update this grub using Terminal:
    sudo update-grub

    Reboot and enjoy <3

    [Reply]

    #3 
    Written By Bacardi on March 25th, 2010 @ 3:26 am

    HI all
    I do that and it is working but now I can’t access the GRUB menu because I made the default time is zero.
    I try to access it by pressing shift and it is not work
    I need help to to access menu grub so I can select ubuntu

    thx alot

    [Reply]

    #4 
    Written By bahaa on June 7th, 2010 @ 12:52 pm

    bacardi’s suggestion works well

    [Reply]

    #5 
    Written By sarah on November 24th, 2010 @ 10:52 pm

    when i use method 3 my windows xp cant boot not
    shown grub ??
    regards
    kjeldsen

    [Reply]

    #6 
    Written By KJELDSEN on March 24th, 2011 @ 10:07 am

    chmod: cannot access `/boot/grub/grub.cfg’: No such file or directory

    [Reply]

    #7 
    Written By arif on June 11th, 2011 @ 4:38 am

    Hi!!

    I do each step but make not the file grub.cfg correctly.

    I changed the permissions, I have grub2 and running update-grub2 however don’t configure.

    Cheers.

    [Reply]

    #8 
    Written By felix on February 25th, 2012 @ 7:52 am

    Other stuff…

    When it’s starting Grub, say something like to “Exist not the partition”, I review and have Windows on /dev/sda2 as second primary partition, and Debian on /dev/sda1 as primary partition.

    Initially, I had Debian, I did install Windows XP, recovery Grub great, but I have this fail with grub :-(

    [Reply]

    #9 
    Written By felix on February 25th, 2012 @ 7:59 am

    I solved, I do a blkid a copy the serial of the partition of Windows, great, all run well.

    Thank you for publish this post.

    Cheers.

    [Reply]

    #10 
    Written By felix on February 25th, 2012 @ 8:32 am

    Add a Comment

    required, use real name
    required, will not be published
    optional, your blog address