Windows XP p2v conversion with KVM

After all of the Windows and Linux virtual machines I have setup I decided to try a Windows p2v (Physical to Virtual) conversion. After bracing for the worst it ended up being fairly straight forward. Steps as follows:

  1. Create a disk image of sufficient size
  2. Copy the Windows HDD to the disk image
  3. Boot the image with KVM

Yip. Only three steps. Beware that Windows p2v images have all run quite slow for me compared to Windows images that were originally installed in KVM. This I guess is just because of the cruft buildup in Windows and all the driver changes that Windows seems to balk at so much.

Although these instructions are written using Window XP as the guest image, it will work equally (extremely) well for Linux too. The only exception with linux being that you can substitute the clonezilla step for a straight tar copy of the images. Using clonezilla for Windows and Linux though reduces the number of different steps to remember.

Create a disk image of sufficient size

I chose to use qcow2 for spaces sake as I am only testing this on my laptop. Feel free to use any type of disk image that KVM supports.

qemu-img create -f qcow2 windowsxp.qcow2 80G

Copy the Windows HDD to the disk image

For this step I pulled the HDD from the machine to convert and connected it via a usb sata converter. The HDD was then accessible at /dev/sdc. However you connect the HDD to your computer, be it internally or externally, you will need to be able to access it as a block device. So just substitute my references to /dev/sdc with the location of your source HDD.

For copying from p2v I chose to use clonezilla again after how handy it has been for resizing NTFS images for me (ref). Download a clonezilla livecd iso from here.

kvm -m 256 -boot d -cdrom clonezilla-live-1.2.1-39.iso -hda /dev/sdc -hdb widowsxp.qcow2

After booting I selected a disk to disk copy and just accepted all of the default options. I will work both with NTFS and FAT32 partitions. The main thing to be aware of when using clonezilla is that the PHYSICAL drive gets selected as the source. It’s description in clonezilla will be similar to the writing on the HDD label.

If you have more than one HDD for this machine then just repeat the above steps for each disk.

If there source machine is using RAID then you first need to burn the clonezilla iso to cd or create a clonezilla live usb stick. Boot the source machine with clonezilla and copy the source HDD to a spare HDD first, then connect the spare HDD to your machine and copy that. Clonezilla does have options for network copy that may save a lot of extra work in this step, but I have not had time to explore them yet.

Boot the image with KVM

On first boot Windows will detect all the hardware changes and install drivers for them. Most emulated hardware in KVM already has drivers in Windows and I did not get prompted for any drivers etc.

kvm -m 512 -usb -usbdevice tablet -hda windowsxp.qcow2

Upon Windows detecting such hardware changes you will also need to reactivate Windows again too. If you are using libvirt then you can also create a new xml definition and manage the image that way.

If you had any static ip addresses defined in Windows these will need to be setup again too as Windows will have detected new network cards. For Ubuntu it is not so much that the network cards have changed but that the MAC address has changed and the new card is likely assigned to eth1 instead of eth0. If you still want the network card referred to as eth0 the edit /etc/udev/rules.d/70-persistent-net.rules and remove the two line referencing your old network card then reboot and your cards will be named correctly. Or just change /etc/network/interfaces to from eth0 to eth1 as appropriate.

This entry was posted in KVM, p2v and tagged , , , , , , . Bookmark the permalink. Both comments and trackbacks are currently closed.


  1. dave
    December 12, 2010 11:28 am

    I know this post is a bit old, but I just tried it and was wondering is there any visual graphic used in the cloning process? IN my qemu window it shows:
    Using ntfsclone to clone…
    Checking NTFS integrity in /dev/hda1… done!
    ntfsclone v2.0.0 (libntfs 10:0:0)

    and then just a blinking cursor. Should there be a progess bar or something? Thanks for the post.

    • December 12, 2010 11:34 am

      I don’t remember there being a progress bar, no. My last p2v conversion was when I wrote this article though.

  2. dave
    December 12, 2010 12:14 pm

    Thanks for your quick response. I’ll see how it turns out! (I tried with the latest version of clonezilla (clonezilla-live-20101207-maverick.iso) and got a non-bootable, unrecognized formatted disk.)

2 Trackbacks