How to Install Windows XP on Centos 5

__NOTOC__
= Introduction =
This procedure shows you how to install Windows under Xen on CentOS5, and fixes one of the big problems of Windows XP under Xen: Windows XP's inability to shut itself down fully (Windows ends up on the 'it is safe to turn off your computer' screen, but the virtual machine is not automatically destroyed). See XenWindowsACPI for a summary of how we achieve this.
We fix Windows XP's inability to shut down the VM properly by manipilating the VM during Windows Setup so that it installs ACPI drivers, despite the fact that Xen's current ACPI implementation seems to cause Windows Setup to choke or stall.
= Caveats =
This may work on other Xen setups, but I've only tested it on CentOS5 on an Intel DQ965GF motherboard.
= Preparation =
This section is optional, and just describes a way that I've set things up that makes it easier to commission more than one VM.
# Create a folder for the ISO image; the folder should be in `/var/lib/xen/images/media`. Name it something like `winxp-pro-corp-X08-31437` (in this case, `X08-31437` is the media part number, but you can use whatever makes sense to you).
# Create the ISO image by putting the disc in the CDROM drive and issue a command such as:
#* `dd if=/dev/cdrom of=/var/lib/xen/images/media/winxp-pro-corp-X08-31437/disc1.iso`
= Procedure =
Note that vmname is the name of the new virtual machine that you are creating.
# Change to `/var/lib/xen/images` (eg: `cd /var/lib/xen/images`)
# Create a symbolic link to the install ISO image: `ln -s media/winxp-pro-corp-X08-31437/disc1.iso `vmname`-install.iso`
# Create a large file to be used as the hard drive of the virtual machine. EG: for a 4GB virtual hard drive:
#* `nice dd if=/dev/zero of=`vmname`.img bs=1M count=4096`
#* (Note that this will take some time, up to a minute per gigabyte, and will slow down the machine, which is why we 'nice' it)
#* You can also create a sparse file, which will only take up space when its written to it. (check du -sh `vmname`.img to see)
#* dd if=/dev/null of=`vmname`.img bs=1M seek=10000
#* This creates a 10G sparse file, which actually takes up no space (yet). You can make huge files, and the OS will think is actually has it.
#* (Also called thin-provisoning)
# Use `virt-install` to start the installation process:
#* `virt-install -n `vmname` -r 384 -f /var/lib/xen/images/`vmname`.img -b xenbr0 --sdl -v -c /var/lib/xen/images/`vmname`-install.iso`
#* Note that this command will create a configuration file `/etc/xen/`vmname, start the new virtual machine, then try to connect to it.
# One of four things will happen:
#* a) The virtual machine will fail to start, or will shut down relatively quickly;
#* b) The virtual machine will start, but will reboot every minute or so (usually at the setup screen that "Setup is starting Windows" at the bottom);
#* c) The virtual machine will start, but will stall on the blue setup screen that says "Setup is starting Windows" at the bottom;
#* d) The virtual machine will start, and will reach the "Welcome to Setup" screen.
# Make a note of which of the four things happened, then issue `xm destroy `vmname to shut down the new virtual machine
# Make the following changes to `/etc/xen/`vmname:
#* Change the line `apic=1` to `apic=0`
#* Change the line `acpi=1` to `acpi=0`
#* Add `file:/var/lib/xen/images/`vmname`-install.iso,hdb:cdrom,r',` to the list in the line `disk = [ ... ]`
#* Add the line `boot = 'd'` (preferably after the line `disk = [ ... ]`, but it shouldn't really matter)
#* Change the line `on_reboot = 'restart'` to `on_reboot = 'destroy'` (this will ensure that Windows doesn't restart during setup without our intervention, which will be required for ACPI support in the guest to be set up properly)
# Re-launch the virtual machine with `xm create `vmname
# Run through the normal Windows setup process. Notes:
#* Format the new partition as NTFS (Quick)
# When Setup tries to reboot, it will instead be shut down. Don't panic, this is intentional and was created by the line `on_reboot = 'destroy'` that we modified in the config file
# Make the following changes to `/etc/xen/`vmname:
#* Change the line `apic=0` to `apic=1`
#* Change the line `acpi=0` to `acpi=1`
#* Change the line `boot = 'd'` to `boot = 'c'`
#* Change the line `on_reboot = 'destroy'` to `on_reboot = 'restart'`
# Continue the setup process by restarting the virtual machine with `xm create `vmname`
# Run through the rest of the normal Windows setup process. Notes:
#* Add the machine to the domain
#* (other notes TBA)
# Install TightVNC in the guest so that you can access the guest remotely
# Shut down the virtual machine (from within Windows, not via `xm`)
# So that the virtual machine can start while we are not logged into the physical machine, make the following changes to `/etc/xen/`vmname:
#* Change the line `vnc=0` to `vnc=1`
#* Change the line `sdl=1` to `sdl=0`
# Boot the virtual machine with `xm create `vmname
# If successful, the virtual machine will not show a display, but will show up in the results of `xm list` and you can connect to it with `vncviewer`, TightVNC, etc.
If something goes wrong and you can't connect via VNC or `rdesktop`, you can use `virt-manager` (aka Applications → System Tools → Virtual Machine Manager) to connect directly to the virtual machine's console and see what it's doing.
Category:Xen
Category:Users
Category:Host Install
Category:CentOS