个人工具

UbuntuHelp:How to dual-boot Ubuntu and XP after installing them separately on two HDs

来自Ubuntu中文

跳转至: 导航, 搜索

Introduction

You have installed Ubuntu on a separate HD because you were afraid to loose things on your Windows disk? You absolutely want to keep XP and Ubuntu separate? Then this might help you. :)

Case 1: You haven't installed Ubuntu yet

Do a fresh install of Ubuntu with the windows hard drive still plugged in. Ubuntu will automatically detect the other hard drive, and Grub will automatically list it as a choice at startup. You can then also see the other hard drive and access it while in Ubuntu by mounting it.

Case 2: You already installed Ubuntu on an HD

Short tutorial

If you were afraid to partition and format another hard drive just for Ubuntu and disconnected the previous one with Windows during the installation, you will run into this problem to have to add Windows boot manually. The solution is simply adding this to /boot/grub/menu.lst:

title		Windows XP Professional
root		(hd1,0)
savedefault
makeactive
chainloader	+1
map (hd0) (hd1)
map (hd1) (hd0)

The parts with (hd1,0),(hd0) (hd1) and (hd1) (hd0) depend on where your Windows partition is, which you can find out by typing:

sudo fdisk -l

In this example, Windows is assumed to be on hd1 and Ubuntu on hd0. The problem is that Windows boot must be on the first hard disk/partition in order to boot. You trick it into thinking that by adding those last two lines with the map command in the Grub menu entry.

Case 3: Windows was installed on the first hard disk, you physically disconnected that hard disk because you were afraid losing data and installed Ubuntu on the second disk

Here, first disk means SATA 0 (instead of SATA 1 or SATA 2) or Primary-Master disk when talking about IDE. The BIOS will always boot the SATA 0 physical disk first (or the Primary-Master IDE disk). When reconnecting the Windows hard disk, you'll notice the system boots in Windows directly and ignores Ubuntu. Since you don't want to fall into installing GRUB in that disk (because, after all, if you disconnected it, it's your important disk), it would be more convenient to ask the BIOS to boot the Ubuntu disk first, where you could easily configure GRUB to list Windows for booting it from the other disk. Unfortunately, that's not always possible. However, the simplest solution is to physically swap your two SATA connections (either on the motherboard or on the disks themselves), or for that matter swap your master/slave IDE hard disks (or primary/secondary... whatever, just make the Ubuntu disk the most important one for the BIOS). Then, you'll notice Ubuntu boots instead of Windows! When Ubuntu finishes booting, just follow the "complete tutorial" section below. Also, you may want to comment the "hiddenmenu" line so that you actually see the menu. You may also want to increase the timeout value, from 3 to about 15 so that it lets you enough time for checking and testing each item.

Complete tutorial (cases 1 and 2)

Backup your menu.lst first:

sudo cp /boot/grub/menu.lst /boot/grub/menu.lst.bkp

Find out where your Windows hard disk is with (if you are confused here just post the result here and someone might help)

sudo fdisk -l

Then you need to add the new entry to grub with

gksudo gedit /boot/grub/menu.lst

And then add the following entry to the very end of the file

title		Windows XP Professional
root		(hd1,0)
savedefault
makeactive
chainloader	+1
map (hd0) (hd1)
map (hd1) (hd0)

The "hd" is always "hd" even if Windows is on a Sata drive. The second line of the map command is just so your Ubuntu hard drive will be recognizeable on Windows. If you need to read/write on Ubuntu partitions from Windows or vice-versa, you need to search for other tools (ntfs-3g and ntfs-config for Ubuntu and ext3 for Windows), but that's outside the scope of this thread. If you need more information on Grub's map command you can find it here.

References

Go back