Come installare XP con Linux a bordo

Scenario: You want to install XP on your machine alongside your existing Linux installation, on the same drive. You have installed Ubuntu already.

Tutorial Summary: We’re going to use the Gnome Partition Editor (Gparted) from the Ubuntu LiveCD to shrink the main Ubuntu data partition on the hard disk and create enough space for an installation of XP.

We’ll then install XP, and, because XP overwrites the master boot record, we’ll restore the GRUB boot loader so that either XP or Linux can be selected at boot time.

This is an updated tutorial from our previous Linux/XP workshop. That version was written using Ubuntu 6.10, whereas this tutorial was written for Ubuntu 7.04.

These steps have been tested in both an ASUS P5AD2-based system with an 80GB Seagate SATA drive and a VMWare 6 virtual machine.

Prepare the Ubuntu System

The assumption is that the Ubuntu system has been installed on a single hard drive which has enough space to accommodate both operating systems.

The first step is to create enough space on the disk to install Windows XP. The Ubuntu Live CD does contains GNOME Partition Editor, which can be used to resize Linux partitions, but the Live CD for Ubuntu 7.04 has an annoying tendency to mount the filesystem while it’s checking it. This causes an partition work to bring up an error. It does work, but it’s messy. So instead we’ll use the GParted LiveCD, which acts independently of the OS and doesn’t give us any grief.

The GParted LiveCD ISO is available here – burn it to CD and boot the system from the disc. The version we used was 0.3.4-7.

Boot the Ubuntu machine from the GParted LiveCD. Depending on your system, you should just need to select the auto-configuration boot option.

Ubuntu & Vista - GParted

During boot, press Enter twice when prompted to select the keymap and language settings. When the main GUI loads, right-click on the main partition (depending on your setup, probably /dev/sda1) and select Resize/Move.

Ubuntu & Vista - GParted Resize

Use the slider to create sufficient space to house the XP installation then click Resize/Move.

Ubuntu & Vista - GParted Resize 2

Once that’s done, quit GParted and reboot the machine from the Windows XP CD.

Now, install Windows XP

Once the CD has loaded, press Enter to install Windows XP, then F8 to accept the license agreement.

When the partition screen loads, you can see that Windows Setup can see the two existing Ubuntu partitions and has interestingly assigned them drive letters (even though it can’t read them.)

The space we’ve just created is also there, so select that and hit Enter.

Windows XP - Select PartitionWindows XP – Select Partition

Because the primary active partition (/dev/hda1) has been marked as bootable, Windows can’t be installed until this partition has been marked inactive so that the new partition can take over. This is pretty much the same as installing Windows Vista. Hit Enter to make this change and then format the new partition.

Windows XP - Mark Partition ActiveWindows XP – Mark Partition Active

Unfortunately because XP detected the two Ubuntu partitions and assigned them drive letters, the new partition which Windows is going to be installed on will be assigned drive letter F:, which is definitely a non-standard drive letter for Windows.

However, it’s not that much of a problem – at least as far as Windows and therefore most other intelligent applications go.

It could be a problem for older apps which don’t look to the Windows settings and make assumptions about where they can install themselves (for example, apps that are hard coded to install to Drive C).

Reboot the system once Windows is installed and you’ll see that it boots straight into XP. Ubuntu’s GRUB bootloader in the MBR (Master Boot Record) has been overwritten, so Ubuntu isn’t bootable at this point in time.

There are ways to make the Ubuntu partition bootable while still using XP’s bootloader in the MBR. However this is fiddly and involves using FAT32 partitions, as FAT32 is readable by both XP and Ubuntu. Wherever possible I avoid using FAT32 – it’s nowhere near as optimised as NTFS, and you lose out on all the enhanced security and permissions features.

Reinstating GRUB as the system bootloader is a much better alternative – it handles pretty much any operating system you care to throw at it, and it’s very easy to administer.

Reinstall GRUB to the MBR

The next step is to reinstate GRUB as the system bootloader. Boot the system using the Ubuntu Live CD.

Go into the GNOME Partition Editor and you can see that the Windows XP Partition is detected as /dev/hda2 and has been marked as the boot partition.

It can actually stay as the boot partition, but as we’re going to reinstall GRUB it makes sense to change this – it doesn’t adversely effect XP.

Right-click the Windows partition and select Manage Flags.

Untick “boot” and select Close.

Then right-click the primary Ubuntu partition (/dev/hda1), select Manage Flags and tick “boot”, then Close. Done.

GParted - Manage FlagsGParted – Manage Flags

GParted - Mark BootableGParted – Mark Bootable

Now to reinstall GRUB. Open up Terminal (Applications, Accessories, Terminal) and type in:

sudo grub

GRUB - sudo grub

This will launch the GRUB application. Now type in:

find /boot/grub/stage1

GRUB - find grub

This will search for where GRUB has been installed, and you should get the result hd(0,0).

Change the active root to this location by typing in:

root (hd0,0)

Now we’re going to reinstall GRUB to the MBR rather than the Ubuntu partition.

If we were going to use the Windows XP bootloader then we’d reinstall GRUB to hd(0,0), but as we’re not, type in:

setup (hd0)

GRUB - reinstall grub to MBR

This restores GRUB to the MBR. Type in QUIT and then EXIT to get out of GRUB and Terminal respectively, then reboot the system. Ubuntu will load by default.

Modify the Boot Menu

What we need to do now is modify the GRUB boot menu to allow Windows XP to load. Boot the system into Ubuntu and go to Terminal. Type in:

sudo gedit /boot/grub/menu.lst


This loads the GRUB menu file (which is basically a text file) within GEdit.

Navigate down to the section which after “## ## End Default Options ##”.

These are the individual menu items in the GRUB menu.

Ubuntu & XP - GRUB MenuUbuntu & XP – GRUB Menu

To create a new entry, navigate down to the end of the list (although it can go anywhere really) and enter the following lines:

title Windows XP

root (hd0,1)

makeactivechainloader +1

GRUB - Windows XP boot option

This places an item in the boot menu to launch Windows XP from its own partition (hd0,1).

If you like, scroll up to the top of MENU.LST and find the line called TIMEOUT.

The numerical value assigned to TIMEOUT dictates how long you’ve got to go into the boot menu (in seconds) before the default boot item loads.

When configuring a dual-/multi-boot system I find it better to increase this value.

GRUB - timeout

Just above TIMEOUT is DEFAULT. This specifies which boot entry is the default.

The numbering system starts at 0 and counts upwards, so the DEFAULT = 0 means that Ubuntu is always the default entry.

If you want Windows XP to be the default, replace the value.

GRUB - default

Save MENU.LST and exit from GEdit, then restart the system.

Hit ESC when prompted to bring up the boot menu, and there’s the newly-created Windows XP entry.

Navigate to this boot item and hit Enter – Windows XP will load.

Uninstalling Windows XP

If you decide after a while that this dualbooting situation is no good and you wish to scrap Windows XP, it’s actually very easy.

Go through the process outlined above to modify the MENU.LST and remove the Windows boot entry.

Then boot off the Ubuntu Live CD and go into GNOME Partition Editor. Right-click the Windows partition (/dev/hda2) and select Delete.

GParted - Delete Partition

Then right-click the main Ubuntu partition (/dev/hda1) and select Resize/Move.

Drag the edge of the partition to reclaim the space you’ve just freed up by deleting the Windows XP partition and click Resize.

There will now be two actions waiting in the Operations window. Hit Apply and these changes are made.

GParted - Remove Windows XP

This take your system right back to the start before Windows was installed, and is actually quite a graceful exit from the dualboot scenario.



Inserisci i tuoi dati qui sotto o clicca su un'icona per effettuare l'accesso:


Stai commentando usando il tuo account Chiudi sessione / Modifica )

Foto Twitter

Stai commentando usando il tuo account Twitter. Chiudi sessione / Modifica )

Foto di Facebook

Stai commentando usando il tuo account Facebook. Chiudi sessione / Modifica )

Google+ photo

Stai commentando usando il tuo account Google+. Chiudi sessione / Modifica )

Connessione a %s...