KVM - The Linux Kernel-Based Virtual Machine
News, Blogs and Resources on the Linux (KVM) Kernel-Based Virtual Machine

Create virtual machine around an existing XP disk

1 reply [Last post]
FakeName
Offline
Joined: Dec 8 2010
Points: 3

This is probably explained in half a dozen places but I have not written the right search argument.
I find a lot of info about installing Windows in a VM but I have an existing, bootable, Windows disk that I want to use as the basis of a virtual machine, currently trying on Ubuntu 10.10 but the Distro is not important.

background:
My wife is having problems with her Dell Inspiron 530 running XP and wants me to fix it. But I don't do Windows.
So I thought I'd;
Buy a new SATA drive for the machine
Put Linux on it
Create a virtual machine and use the old drive with the problematic XP install on it as the HDD

With this configuration I was hoping to have her use Linux for surfing and watching youtube and what ever, and she could go to the virtual machine to do anything that "really needed" Windows.

So the install went OK and Grub will even boot the XP machine if I select it, but the virtual, ... nope.
I get a "STOP 7B" BSOD indicating a problem with the sata drive

I don't think I could find the original MS CD if we even got it when we got the machine and that would somehow get me back into working the Windows, which I really do not want to do.

The question:
So what is happening to keep Windows from starting?
Is kvm doing the I/O and feeding XP the data in a way that it is not used to seeing it?
I'd like to know where my plan is breaking down, and perhaps a way to do it so that it works.

The drive is readable by Linux so is there something that can be done by simply adding a file to the right directory or booting to Windows and editing the registry?

ash
Offline
Joined: Dec 19 2010
Points: 2
The way to create a VM from an existing machine

I've migrated several physical machines - Windows and Linux - to virtual ones under KVM. In fact I just did an XP box yesterday. Here is how I did it.

Background:

I've got a Dell Optiplex that I just installed Fedora 14 on.

I've got a Compaq Presario that I want to retire. The Compaq has an 80 Gig drive with XP on it, I'm only using about 20 Gigs of it.

I don't want to put the Compaq drive in the Dell, but rather take an image of it. There are a number of reasons to do it this way, all outside of the scope of this post, but I've had fantastic results doing it this way.

Getting started:

This first step is optional: Download sdelete, (http://technet.microsoft.com/en-us/sysinternals/bb897443) and run sdelete -c to zero out the free space on the drive. This will be beneficial if you create your disk image compressed.

Now create an image of your old hard disk. The easiest way to do this is to hang the disk off of your host system and run something like:

# qemu-img convert -c -O qcow2 /dev/sdX hdd-image-name.qcow2

assuming you want qcow2 format. man qemu-img for more options/info. Adjust /dev/sdX as appropriate.

When this completes, you'll have an image of your hard disk.

Now create your Virtual machine. For convenience, I'll use the graphical "Virtual Machine Manager". I told it to use an existing disk image, the one I just created.

At this point, you could just boot up the virtual machine you just created, but performance will suck. Why? Because Virtual Machine Manager just created my Windows XP VM with IDE drives, which perform horribly. You want virtio drives. Switch to the details screen of your VM (under Virtual Machine Manager), and delete the IDE HDD and replace it with a VirtIO HDD. Also go into the NIC and make sure it is using a VirtIO driver for the NIC.

Go ahead and add a floppy and CD ROM. For the floppy, link it to the floppy image from here:

http://alt.fedoraproject.org/pub/alt/virtio-win/latest/images/bin/

also download the CD ROM image from there for later use.

Final component you'll need is your Windows XP CD, and your CD Key. Windows won't boot with the VirtIO devices, so you'll have to boot off of the Windows CD to do a "repair installation":

http://www.microsoft.com/windowsxp/using/helpandsupport/learnmore/tips/d...

when you first boot off of the CD, make sure you press F6 to load any additional drivers. You'll need to load the VirtIO drivers off of your virtual floppy you added to your VM above.

Note: If you are not offered the "repair installation" as outlined above, make sure you are using the same XP CD version as was used to install the system originally.

After the repair installation is complete, your XP installation will boot. You may be prompted to reactivate windows (you would be prompted for this anyway due to the fact that your hardware significantly changed).

After you boot, go into device manager and add the drivers for you NIC device, which are available on the VirtIO iso you downloaded above.

At this point, everything should be working. Enjoy your XP VM!

Post new comment

The content of this field is kept private and will not be shown publicly.
Type the characters you see in this picture. (verify using audio)
Type the characters you see in the picture above; if you can't read them, submit the form and a new image will be generated. Not case sensitive.