Running Windows XP in Xen from its own partition
Some months ago I made some experiments with Xen and I succeeded to install and run Windows XP as a guest using Xen 3.0. In that case Windows was located in a single file and was installed through Xen. My purpose now is to make Xen running an already installed Windows from its own partition. Just to be more specific, this is my machine configuration:
- Ubuntu Dapper Drake 6.06 is located on a SATA disk, set as first boot disk
- Windows XP is located on a EIDE disk, set as second boot disk
- Dual boot is made by grub
I previously tried to reach this goal but I only got grub error "GRUB loading stage 1.5" and "Error 21", meaning an unknown error during the boot process.
After upgrading the packages Ubuntu was proposing I decided to try again and I downloaded and compiled Xen 3.0.4 (see the packages to be installed first in my other post about running Windows inside Xen):
# cd /usr/src # hg clone http://xenbits.xensource.com/xen-3.0.4-testing.hg # cd xen-3.0.4-testing.hg # make world # make installThe next steps are exactly the same I wrote here, replacing 18.104.22.168 with 22.214.171.124 as the kernel version and 3.0.2-3 with 3.0.4-1 as Xen version. I briefly report them here:
# mv /lib/tls /lib/tls.disabled # cd /boot # /sbin/depmod -a 2.6.16-xenEdit /etc/mkinitramfs/modules:
# cd /boot # mkinitramfs -o initrd.img-126.96.36.199-xen 188.8.131.52-xen # ln -sf initrd.img-184.108.40.206-xen initrd.img-2.6-xenIn /boot/grub/menu.lst I did nothing because I already had this:
title Xen 3.0 / XenLinux 2.6 kernel /boot/xen-3.gz dom0_mem=1024000 module /boot/vmlinuz-2.6-xen root=/dev/sda1 ro module /boot/initrd.img-2.6-xen(my machine has 2GB of RAM: I reserved 1GB to Xen and I will give the other 1GB to Windows guest).
Instead I had to do these steps again:
# mv /etc/udev/rules.d/xen-backend.rules /etc/udev/rules.d/92-xen-backend.rulesThen edit /etc/init.d/xend after "/proc/xen/capabilities":
if [ ! -d /var/run/xend ] ; then mkdir -p /var/run/xend fi if [ ! -d /var/run/xenstored ] ; then mkdir -p /var/run/xenstored fiAnd edit /etc/init.d/xendomains:
LOCKFILE=/var/lock/xendomainsAfter rebooting my pc I checked Xen was using 1GB only:
# xm list Name ID Mem(MiB) VCPUs State Time(s) Domain-0 0 965 2 r----- 132.5
I already knew that my pc has AMD hardware virtualization capabilities, but let's check again if it's enabled (look for
# cat /proc/cpuinfo | grep svm flags : fpu tsc msr pae mce cx8 apic mtrr mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx mmxext fxsr_opt lm 3dnowext 3dnow pni cx16 lahf_lm cmp_legacy svm cr8_legacy flags : fpu tsc msr pae mce cx8 apic mtrr mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx mmxext fxsr_opt lm 3dnowext 3dnow pni cx16 lahf_lm cmp_legacy svm cr8_legacy # xm dmesg | grep SVM (XEN) AMD SVM Extension is enabled for cpu 0. (XEN) AMD SVM Extension is enabled for cpu 1.
And now the challenge begins!
- Configure Xen image to start Windows XP:
# mkdir /etc/xen/vm # cp /etc/xen/xmexample.hvm /etc/xen/vm/winxp.hvmand make these changes to /etc/xen/vm/winxp.hvm:
name = "winxp" memory = 1024 disk = [ 'phy:/dev/sda,ioemu:hda,w', 'phy:/dev/hda,ioemu:hdb,w' ] on_poweroff = 'destroy' on_reboot = 'destroy' on_crash = 'destroy' cdrom='/dev/hdc' boot='c' sdl=1 vnc=0 vncviewer=0I reserved 1GB of memory to Windows guest, I set both my disks to be seen by the guest (my SATA disk will be seen as the first EIDE disk to boot from and my EIDE disk will be seen as the second boot disk to boot from), and I told Xen to use sdl instead of vnc.
- Check grub menu options; this is my /boot/grub/menu.lst:
title WinXP map (hd0,0) (hd1,0) map (hd1,0) (hd0,0) rootnoverify (hd1,0) chainloader +1 title Xen 3.0 / XenLinux 2.6 amd64 1G kernel /boot/xen-3.gz dom0_mem=1024000 module /boot/vmlinuz-2.6-xen root=/dev/sda1 ro module /boot/initrd.img-2.6-xenThe disk mapping is needed to make Windows think it's on the first disk, otherwise it won't start.
Reboot and choose Windows XP, first to make sure to be able to boot Windows (it's not my case because I've been using such a configuration for months), and to copy the Windows Hardware Profile to a new one: go to Settings -> Control Panel -> System, select Hardware, then Hardware Profiles and Copy the current profile to a new one, which I called VM.
- Start Windows XP guest:
# cd /etc/xen/vm # xm create winxp.hvm Using config file "winxp.hvm". Started domain winxpA new window opened showing initially the boot process and then my usual grub menu, with the WinXP and Xen choices: it's fundamental to choose WinXP because accessing the same partition from the host and the guest (in case Xen was chosen) may be fatal.
Then Windows boot menu appeared with the two hardware profiles available: Windows and VM: I chose VM, otherwise my standard profile will be changed loading the drivers for Xen virtual machine specifications.
Windows started and showed the login window, and after logging in my Windows appeared, with my desktop, my menus, my programs.
And this is Xen status:
root@am2:/etc/xen/vm# xm list Name ID Mem(MiB) VCPUs State Time(s) Domain-0 0 965 2 r----- 3451.7 winxp 2 1032 1 r----- 7542.4