PDA

View Full Version : [ubuntu] Add Windows XP to Grub 2



Equerm
June 30th, 2009, 10:07 AM
I recently installed Ubuntu 9.10 Karmic Koala and Grub2 followed with it. But my Windows XP installation did not follow in the Grub2 setup, does anyone know how to add Windows XP to grub2?

For the record Grub2 does not contain a menu.lst file, it got a grub.cfg file, this file does not use the standard grub code that i am used to. It looks like this


#
# DO NOT EDIT THIS FILE
#
# It is automatically generated by /usr/sbin/grub-mkconfig using templates
# from /etc/grub.d and settings from /etc/default/grub
#

### BEGIN /etc/grub.d/00_header ###
set default=0
set timeout=5
set root=(hd1,7)
search --no-floppy --fs-uuid --set 7cece53a-77f2-4714-abd2-cd4d29e14c16
if loadfont /usr/share/grub/ascii.pf2 ; then
set gfxmode=640x480
insmod gfxterm
insmod vbe
if terminal_output gfxterm ; then true ; else
# For backward compatibility with versions of terminal.mod that don't
# understand terminal_output
terminal gfxterm
fi
fi
### END /etc/grub.d/00_header ###

### 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, Linux 2.6.30-10-generic" {
set root=(hd1,6)
search --no-floppy --fs-uuid --set c85c3571-0842-4cc7-bcf0-c4b02b43fbf6
linux /vmlinuz-2.6.30-10-generic root=UUID=7cece53a-77f2-4714-abd2-cd4d29e14c16 ro quiet splash
initrd /initrd.img-2.6.30-10-generic
}
menuentry "Ubuntu, Linux 2.6.30-10-generic (recovery mode)" {
set root=(hd1,6)
search --no-floppy --fs-uuid --set c85c3571-0842-4cc7-bcf0-c4b02b43fbf6
linux /vmlinuz-2.6.30-10-generic root=UUID=7cece53a-77f2-4714-abd2-cd4d29e14c16 ro single
initrd /initrd.img-2.6.30-10-generic
}
menuentry "Ubuntu, Linux 2.6.30-9-generic" {
set root=(hd1,6)
search --no-floppy --fs-uuid --set c85c3571-0842-4cc7-bcf0-c4b02b43fbf6
linux /vmlinuz-2.6.30-9-generic root=UUID=7cece53a-77f2-4714-abd2-cd4d29e14c16 ro quiet splash
initrd /initrd.img-2.6.30-9-generic
}
menuentry "Ubuntu, Linux 2.6.30-9-generic (recovery mode)" {
set root=(hd1,6)
search --no-floppy --fs-uuid --set c85c3571-0842-4cc7-bcf0-c4b02b43fbf6
linux /vmlinuz-2.6.30-9-generic root=UUID=7cece53a-77f2-4714-abd2-cd4d29e14c16 ro single
initrd /initrd.img-2.6.30-9-generic
}
menuentry "Ubuntu, Linux 2.6.30-8-generic" {
set root=(hd1,6)
search --no-floppy --fs-uuid --set c85c3571-0842-4cc7-bcf0-c4b02b43fbf6
linux /vmlinuz-2.6.30-8-generic root=UUID=7cece53a-77f2-4714-abd2-cd4d29e14c16 ro quiet splash
initrd /initrd.img-2.6.30-8-generic
}
menuentry "Ubuntu, Linux 2.6.30-8-generic (recovery mode)" {
set root=(hd1,6)
search --no-floppy --fs-uuid --set c85c3571-0842-4cc7-bcf0-c4b02b43fbf6
linux /vmlinuz-2.6.30-8-generic root=UUID=7cece53a-77f2-4714-abd2-cd4d29e14c16 ro single
initrd /initrd.img-2.6.30-8-generic
}
### END /etc/grub.d/10_linux ###

### BEGIN /etc/grub.d/20_memtest86+ ###
menuentry "Memory test (memtest86+)" {
linux /memtest86+.bin
}
menuentry "Memory test (memtest86+, serial console 115200)" {
linux /memtest86+.bin console=ttyS0,115200n8
}
### END /etc/grub.d/20_memtest86+ ###

### BEGIN /etc/grub.d/30_os-prober ###
### END /etc/grub.d/30_os-prober ###

### BEGIN /etc/grub.d/40_custom ###
# This file is an example on how to add custom entries
### END /etc/grub.d/40_custom ###

swerdna
June 30th, 2009, 12:04 PM
Add this entry with a sudo text editor (gksu gedit /boot/grub/menu.lst):

title Windows bootloader access
rootnoverify (hd0,0)
chainloader (hd0,0) +1
You adjust hd(0,0) to match the partition where xp's boot.ini file resides.

Sometimes you have to add the map function if xp was installed on a different drive whaich was addressed differently after the addition of Ubuntu. That's like this:

title Windows bootloader access
map (hd0) (hd1)
map (hd1) (hd0)
rootnoverify (hd1,0)
chainloader (hd1,0) +1

Ayrton
November 7th, 2009, 04:38 PM
Hi,

I have upgraded to Ubuntu 9.10 recently, which resides in a partition of my first drive:


/dev/sda7: UUID="ddca03a1-2716-4b14-8436-f77784f25b88" TYPE="ext4"Now I'd like to add the existing Windows XP boot to the Grub2 boot loader. The Windows XP boot.ini and the OS itself are in this partition of the second drive:


/dev/sdb5: UUID="4A6077FC6077ED57" LABEL="Windows" TYPE="ntfs"I added the code below to menu.lst and then run 'sudo update-grub', but still no luck.


title Windows bootloader access
map (hd0) (hd1)
map (hd1) (hd0)
rootnoverify (hd1,5)
chainloader (hd1,5) +1 I then added this at the bottom of grub.cfg:


menuentry "Windows NT/2000/XP (loader) (on /dev/sdb5)" {
insmod ntfs
set root=(hd1,5)
search --no-floppy --fs-uuid --set 4a6077fc6077ed57
drivemap -s (hd0) ${root}
chainloader +1
}

The menu entry is displayed in the Grub boot screen, but when I select the Windows XP Loader option, a blank screen appears. I guess I'm not addressing the partition correctly so the boot.ini file is not found.

Could somebody help me editing the Grub boot loader?

Thanks!

Mark Phelps
November 7th, 2009, 05:14 PM
Add this entry with a sudo text editor (gksu gedit /boot/grub/menu.lst):

Did you even bother to read the thread title? It clearly says "Grub 2" -- which does NOT use menu.lst!

oldfred
November 7th, 2009, 05:34 PM
You should not directly edit grub.cfg. You can add entries to /etc/grub.d/40_custom or create new files with 2 digits and an underscore where the numeric order is where the custom entries get added into grub.cfg.

If you directly edit grub.cfg the next update will erase your entries.

Copy your entry to 40_custom but try changing the drivemap from hd0 to hd1.
drivemap -s (hd1) ${root}
Or try drivemap with hd0 and hd1 in place of the root
drivemap -s (hd0) (hd1)

I do not know if 40_custom defaults to executable or not but all files must be flagged executable to be included in grub.cfg.

Finally, don't forget to run either the 'sudo update-grub' or 'sudo grub-mkconfig' command.
sudo grub-mkconfig -o /boot/grub/grub.cfg

Ayrton
November 7th, 2009, 06:57 PM
Thanks a lot oldfred! I'll give it a try and let you know if it works.

jheaton5
November 7th, 2009, 09:29 PM
I suspect you just need to run update-grub2 as root.

Ayrton
November 9th, 2009, 06:17 PM
Well, it seems like Grub finally finds my boot.ini, however there seems to be something wrong with the addressing of the partition with the OS in that file... I gave up and now I'm running WinXP using a VM with VirtualBox.

Thanks for your input!

sawick61
November 11th, 2009, 10:03 PM
I suspect you just need to run update-grub2 as root.

i had a similar issue and your quote worked, thanks!!

anystupidname1
November 22nd, 2009, 12:22 AM
sudo update-grub2
worked for me too, thanks!

miros84
January 3rd, 2010, 12:08 AM
worked for me too, thanks!

worked for me too

But i think grub2 is more dificult, why?
is not the idea to be easy?

Tkanoff
May 10th, 2010, 12:14 PM
worked for me! Big thanks :KS

zong1
June 28th, 2010, 10:03 AM
worked for me too

But i think grub2 is more difficult, why?
is not the idea to be easy?

No, it is not.

People on projects come and go. New ones, free with new ideas arrive, and being young and fresh, think that they can change the world with their new ideas. They know that they can, and they will; This is part of youthfulness: Boundless ideas in a lake of stupidity. Its a bit like the man who introduces speedhumps across Britain. These are everywhere and no one likes these. I read once that, now this man has grown wise, he regrets his zeal to push speedbumps out. It was a bad idea. (Especially for those with spinal injuries in backs of ambulances, or ambulancemen in a hurry to get someone to hospital)

Anyway, apparently, /etc/init.d and symbolically linked scripts in /etc/rc?.d, and along with inetd, were far too crap and useless! Thus these were replaced with thousands of new scripts, that did the same, yet required a bright mind to work out what went where. A real pain in the **** to debug it when it goes **** up. My advice, use FreeBSD. Much better.

I recommend Solaris, but its going down the same route. However, its still a lot easier to admin than Linux these days and ZFS is simply amazing.

Yes, Grub was easy to understand, and had no dependencies, as such, on the O/S. Grub2 does the same thing as Grub, but may to be difficult to use. If I want to edit the start-up, independently of the O/s, then I have to watch out, because another O/S may well overwrite it using different files. Bright young minds eh :)


GRUB Legacy:
It is older and no longer developed, but works great and has proven its worth many times over. Editing the GRUB menu is a very simple thing and require little skill on the behalf of the user, save for making sure the right syntax is followed.

Anyway, to add WinXP to GRUB2, without using the update-grub, then edit the file /boot/grub/grub.cfg and add these lines at the end of the file:
NB: Change the 9 value in hd0,9 to the disc you have Windows on. If /dev/sda1 then change to hd0,1 (Mine is on on /dev/sda9).
NB. there are two instances of hd0,9 to change.
menuentry "Windows " {
set root=(hd0,9)
chainloader (hd0,9)+1
}
Afterwards, Windows will appear on grub at boot time. If you run update-grub, the entry will disappear.

If you want to make this a permanent change then edit this file:
/etc/grub.d/40_custom
and add the same lines as above to the end of the file. Shown below in bold below:

#!/bin/sh
exec tail -n +3 $0
# This file provides an easy way to add custom menu entries. Simply type the
# menu entries you want to add after this comment. Be careful not to change
# the 'exec tail' line above.
menuentry "Windows " {
set root=(hd0,9)
chainloader (hd0,9)+1
}

Now run : update-grub

otjutt
March 11th, 2011, 07:10 PM
I suspect you just need to run update-grub2 as root.

I've wondering for two months how to dual boot windows xp and ubuntu once we have installed windows and then installed ubuntu overwriting the mbr. You just solved my problem with such an ease! Thanks you soooooooooooooooooooo much!

HATS OFF! :popcorn:

upapilot
December 27th, 2011, 08:54 AM
Anyway, to add WinXP to GRUB2, without using the update-grub, then edit the file /boot/grub/grub.cfg and add these lines at the end of the file:
NB: Change the 9 value in hd0,9 to the disc you have Windows on. If /dev/sda1 then change to hd0,1 (Mine is on on /dev/sda9).
NB. there are two instances of hd0,9 to change.
menuentry "Windows " {
set root=(hd0,9)
chainloader (hd0,9)+1
}
Afterwards, Windows will appear on grub at boot time. If you run update-grub, the entry will disappear.

If you want to make this a permanent change then edit this file:
/etc/grub.d/40_custom
and add the same lines as above to the end of the file. Shown below in bold below:

#!/bin/sh
exec tail -n +3 $0
# This file provides an easy way to add custom menu entries. Simply type the
# menu entries you want to add after this comment. Be careful not to change
# the 'exec tail' line above.
menuentry "Windows " {
set root=(hd0,9)
chainloader (hd0,9)+1
}

Now run : update-grub


I tried to add windows using the second method (permanent one) but terminal says the update-grub command does not exsit.

spiky001
December 27th, 2011, 08:58 AM
sudo update-grub