September 4, 2010, Saturday, 246

Windows XP in XEN

From ezUnix

Jump to: navigation, search
                                    pdf_icon.png Download this article as a single PDF document 

Contents

Introduction

Xen is like the Mach microkernel, where you can have multiple operating systems running at once and a thin kernel handles switching between them and managing device access. This thin layer in Xen is called the hypervisor, and is analogous to the Mach microkernel. It provides an idealized hardware layer that you port your OS to, and in return you get the ability to run multiple operating system instances at once (e.g., run two copies of Redhat's latest, one copy of the Novell Desktop, and an NetBSD), freeze and restore snapshots of a running OS, and more.


Requirements

CPU with Intel's VM or AMD's AMD-V technology.
A CD with Windows XP.
XEN installed on your system.


To check if your CPU supports virtualization check the /proc/cpuinfo file and see if the flags section shows vmx (Intel) or svm (AMD).


You may need to enable virtualization capabilities in your BIOS as well.


Preparation

Create the Xen disk image. This image file will be used as a "hard drive" for your installation.
Value of count is 1024*X where X is number of Gbytes, 20 in our case.

# dd if=/dev/zero of=winxp.img bs=1M count=20480


Installation

Install meta package with all the software needed to run a XEN DOM0 server:

# apt-get install ubuntu-xen-server

You will need to reboot your computer and boot the XEN kernel. It will be automatically added to your grub menu.

After reboot you may want to start xen tools with following command:

# /etc/init.d/xend start


Configuration files

Edit /etc/xen/xend-config.sxp and make sure the (network-script network-bridge) and (vif-script vif-bridge) options are not commented.
This is to be able to bridge networking your interface with virtual networking interface of XEN, to make things easier.


Now create a HVM enabled configuration file for our XEN DOMU host in /etc/xen/ called winxp

#Kernel and memory size
kernel = '/usr/lib/xen/boot/hvmloader'
builder = 'hvm'
memory  = '512'
vcpus=1
pae=0
acpi=0
apic=0
#cpus = 
device_model = '/usr/lib/xen/bin/qemu-dm'
disk = [ 'tap:aio:/home/fridge/virtual/windows/winxp.img,ioemu:xvda,w', 'phy:/dev/scd0,ioemu:xvdc:cdrom,r' ]
#disk = [ 'tap:aio:/xen/winxp.img,ioemu:xvda,w', 'tap:aio:/some_place/winxp.iso,ioemu:xvdc:cdrom,r' ] 
#disk = [ 'phy:/xen/winxp.img,ioemu:hda,w', 'file:/some_place/winxp.iso,ioemu:hdc:cdrom,r' ]

#  Hostname and Networking
name = 'winxp'
vif = [ 'type=ioemu, bridge=xenbr0, mac=00:00:00:ff:fe:01' ]

#  Behaviour
boot = 'd'  #d is cdrom boot, c is disk boot.
nographic='0'
vnc = '01'
vncviewer = '1'
sdl='0'
audio='1'
soundhw='sb16'
stdvga='0'
serial='pty'
ne2000='0'
on_poweroff = 'destroy'
on_reboot   = 'restart'
on_crash    = 'restart'

Note that the "boot='d'" designates that this Xen image should boot off of the 'cdrom image'.
This is required for the initial boot - and will be changed to "boot='c'" once the hard drive image has Windows installed on it.

Also note that this image is set to place the console onto a VNC enabled terminal.

You can also use SDL to access the graphics console.

Here you can find a fully commented config file: Windows.txt

Installing Windows XP in XEN

Restart XEN after you changed the config files:

# /etc/init.d/xend restart

Put your Windows XP install CD into CD tray and begin installation:

# xm create winxp

It should show something like

# xm create winxp
Using config file "/etc/xen/winxp".
VNC= 1
Started domain winxp


Then quickly in another terminal (on another machine if you like) start up vncviewer to connect to your installation screen (using localhost in this case).

# vncviewer  127.0.0.1:0

Note that the VNC session number (:0 above) matches to the Xen Domain ID for the session you just created.
A 'xm list' on the DOM0 kernel will reveal what your current number is.


IMPORTAND!: After passing the 1st screen of Windows setup of install XP, you will see at the bottom of the screen is the option to press F6 if you need to install a SCSI or RAID controller.
Don't press F6. Press F5 instead. You will then get a menu where you select Standard PC or Standard PC with C-Step i486.

Press F8 when prompted to accept license and chose Send F8 from the vncviewer menu that pops up.
Create NTFS file system and continue installation.


Once installed - using rdesktop

Don't be too worried about the problems with the VNC console. You only really need to use it to do the initial install & setup.
Once that is done - you can use Windows Remote Desktop to connect to your virtual Windows machine.
And - on Linux (and other Unix's) there is a nice RDP client called rdesktop .
Once your system has been installed you can enable the RemoteDesktop via the following tab in Windows:

ControlPanel->System->Remote tab

Enable that - and you can then connect to your client with Remote Desktop.
At this point you're good to go.


Cave Cats

The vncviewer may hang sometimes not showing any progress. Simply restart it to fix this problem.
When Windows restart during installation you will have to run xm create winxp again.


Additional Software

To make your life easier you may want to install virt-manager which is a desktop user interface for managing virtual machines.


Screenshots

And some obligatory screnshots:


Installation: Image:Winxp1-small.png


Windows XP running in XEN: Image:Winxp2-small.png


References


YazzY


Name (required):

Comment: