Install Windows XP in Xen CentOS

In a former post, we know how to use OpenVZ to create virtual system in CentOS, this article will show you how to install Windows under Xen on CentOS 5.3.

We fixed one of the problems of Windows XP under Xen. Windows XP’s inability to shut itself down completely. Windows ends up on the ‘it is safe to turn off your computer’ screen, but the virtual machine is not destroyed. See XenWindowsACPI for a summary.

Preparation Windows image

To create windows installation image is optional, and just describes a way that I’ve set things up that makes it easier to commission more than one VM. You can also use /dev/cdrom instead with the help of virt-manager.

Create a folder for the ISO image. the folder could be named like this /tmp/windows, we’ll use this directory to store a windows dump image from CDROM.

Put your windows installation disc in the CDROM drive.When it’s mounted, issue a command as follows:
dd if=/dev/cdrom of=/tmp/windows/windows-xp.iso

If the CDROM cannot mounted automatically, you might need to mount it yourself. It would take a long time to dump a full windows images depending on the disc’s size.

Create DISK file for Virtual Server

After that, we need to create a disk image file for the virtualized WinXP. Here we store this file in a new sub directory /srv/xen. You might need to create this directory yourself if you are using CentOS. The hard drive of the virtual machine can be created like this:

nice dd if=/dev/zero of=/srv/xen/winxp.img bs=1024k seek=4096 count=0

Dont forget that raw disk is also supported by Xen.

Install Windows in Xen Container

Then we can start the installation process with help of virt-install command:

virt-install -n winxp -r 256 -f /srv/xen/winxp.img -b xenbr0 --sdl -v -c /tmp/windows/windows-xp.iso

This command will create a configuration file /etc/xen/winxp, start the new virtual machine,  and try to connect to it. Here’s a bit problematic. As you  may wonder how we gain the access to windows graphic desktop during the installation.

Generally there are two ways:
1, Using the physic server’s graphic instead. When you have grphic access to physic server, you can use virt-manager’s grphic interface to control the process.
2, You can use VNC client to connect virtual windows XP directly. By default when the installation started, there’s a VNC server running at localhost. It’s configurable in /etc/xen/winxp, you can set which socket it should bind to, and what password can be used to connect this running windows.

Some other adjustings to /etc/xen/winxp are highly recommended. We need to make note that when any error happened, the winxp should be shut down soon not hanging or doing some other crappy things that only god knows.

  • ‘on_crash‘ should be changed to ‘destroy‘.
  • Change the line on_reboot = ‘restart’ to on_reboot = ‘destroy’. This will ensure that Windows doesn’t restart during setup without our permission, which will be required for ACPI support in the guest to be set up properly.
  • Add file:/var/lib/xen/images/winxp-install.iso,hdb:cdrom,r’, to the list in the line disk = [ … ]
  • Add new line boot = ‘d’ (preferably after the line disk = [ … ].).

There’s a sample config file for windows XP in Xen:

name = "winxp"
uuid = "821cc805-ecc3-cc1a-20de-79d4bc99c134"
maxmem = 256
memory = 256
vcpus = 1
builder = "hvm"
kernel = "/usr/lib/xen/boot/hvmloader"
boot = "d"
pae = 1
acpi = 1
apic = 1
localtime = 0
on_poweroff = "destroy"
on_reboot = "destroy"
on_crash = "restart"
device_model = "/usr/lib64/xen/bin/qemu-dm"
sdl = 0
vnc = 1
vncunused = 1
vnclisten = ""
vncpasswd = "virtual-chen"
keymap = "en-us"
disk = [ "file:/srv/xen/winxp.img,hda,w", "file:/tmp/windows/windows-xp.iso,hdc:cdrom,r" ]
vif = [ "mac=00:13:34:ae:70:3b,bridge=xenbr0" ]
serial = "pty"

Then re-launch the virtual machine with “xm create winxp“,and use VNC to connect the virtual OS, and direct the installation process. When finished, 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.

Things to do when installation finished

Now we need to recover the settings that we’ve made to /etc/xen/winxp:

  • 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 winxp“. Run through the rest of the normal Windows setup process, for example add the machine to the domain.

Install TightVNC in the guest so that you can access the guest remotely, so that the virtual machine is accessble while we are not logged into the physical machine. Boot the virtual machine with xm create winxp. 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.

Trouble shooting

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. Please keep note that using virt-manager depends on graphic destop at the physical server, which always eats lots of system resournces.

For other issues please logon our support forum Virtualization, and raise a thread there.  You can also ask Citrix for help directly at their forum.

Share Button

6 thoughts on “Install Windows XP in Xen CentOS

  1. it works with full virtualization but what about para-virtual? virt-install complains about not able to install off cdrom, both image and physical device. surely ms is not distributing some para-enabled disk around, so how is that made possible?

  2. this truly assists, now i receive the problems and i donot know how to work out,
    i search yahoo and discovered your blog,
    thanks once morejust one thing, can i post this entry on my blog? i will add the source and credit to your site.regards!

  3. Your mode of explaining everything in this piece of writing is in fact fastidious, all be capable of easily be aware of it, Thanks a lot.

Leave a comment

Your email address will not be published. Required fields are marked *