P2V migration of a Windows 2000 machine on a (libvirt managed) KVM virtualized guest

Like many of sysadmin around this world, we've got some old boxes lying around, running old software on old OSes. Well, in this case this is that old : a Pentium II machine running ERP software on Windows 2000. The box isn't directly used. The management staff access it through VNC from their own machine. The reason of that setup is a bit odd (users on Mac, software available only under windows...) but that's another story. The fact is this is important software that management staff have to access for important stuff so data conservation itself is pretty much critical. Back to that old box. More and more noise (failing fans, failing hard drive, ...). Sounds like we are gonna be loosing this machine in no time. Next to it, a shining new Linux server box running on shiny new Athlon processor with virtualization instructions enabled is lying with its brand new raid-enabled hard-drives. You guess what we decided...

There's basically the following steps :

  • Tune the original windows installation to make sure it'll boot on the new hardware ;
  • Make an image of the hard drive (or several images if you got several disks) ;
  • Prepare the guest configuration ;
  • Boot and tune back the windows installation.
  • The nice thing is all the steps are essentially covered by tools.

    Tune the original windows installation.

    If you miss that step, you gonna lose plenty of time wondering why windows does not boot anymore. This is because that kind of migration is kinda like putting the hard drive of a windows computer into a different computer (in terms of internal hardware, such as the disk controller). Windows 2000 will try to initialize itself with the wrong disk controller driver and you'll end up with a INACCESSIBLE_BOOT_DEVICE BSOD.

    The key here is to enable the "Default IDE driver" that match all kind of controller (I'm assuming the original hardware is some sort of IDE disk controller and the KVM guest will be emulating an IDE disk too). In french, that driver is named "Standard Dual Channel PCI IDE Controller". Setup that by going to the hardware manager and selecting "Update driver" and then choosing the right one manually in the list.

    Then save, reboot to check it works and shut down the computer.

    Create the disk image.

    There's plenty of methods and software to do it. I used virt-p2v [1] from a Red-Hat guy. Basically, you retrieve the ISO, burn it and boot your box with it. You'll be prompted to configure the local network so do it appropriately. Then the IP of the target virtualization Linux host will be asked. Setup correctly the destination path. Next, you'll be prompted to choose wich disks to copy and which is the boot partition. You'll then have a change to configure the most basic settings of the KVM guest configuration (processor type, RAM amount, ...). This will generate a basic xml configuration along with the drive image. I personnally used my own template but we're not discussing the KVM setup today.

    Start and wait (it took me ~1h30 to copy the 14GB drive of that box).

    Prepare the guest configuration.

    If the image creation finish correctly, you'll end up with a image of the drive on your virtualization host. Prepare the KVM host to point to that image. Adjust the network settings : you can steal the original MAC address or use a random one. I prefer use a new one and change the DHCP server configuration, just in case the old box is turn back on, another day later.
    virsh define ... and virsh start your domain.

    Boot and tune back the windows installation.

    Connect to your guest by using virt-manager or VNC directly. You should get your windows installation in a degraded video mode. This is normal as Windows has to check the "new" hardware and configure its drivers appropriately. Once done, your box is virtualized, the old hardware can now die peacefully and you should be able to sleep correctly knowing the accounting data of your company aren't to be lost tomorrow. But ! This doesn't prevent you to setup a good backup routine as the host is now virtualized, its easy to take a snapshot of the guest and send it to a safe location one a week or more.

    [1] http://people.redhat.com/~rjones/virt-p2v/