Migrate Hyper-V Windows Guest to KVM w/ libvirtd

Microsoft Hyper-V is a great hypervisor if all you have are Windows guests. Unfortunately, the support for Linux guests is not the greatest. KVM, on the other hand, has great support for both Windows and Linux guests. For this reason, I’ve been working on moving the hypervisor I have in my home from Hyper-V to KVM.

KVM BannerThis post will detail the steps necessary to migrate a Windows guest from Hyper-V to KVM. The version of Hyper-V I’m running is 2012R2 and the guest is Windows 8.1.

Install VirtIO drivers

The first step is to install the VirtIO drivers on the Windows guest, while it is still running on Hyper-V. Download the latest VirtIO drivers ISO from the Fedora Project.

Mount the ISO in your guest. Browse the ISO, diving into the folder for your version of Windows. In this case, Windows 8/8.1 and Windows Server 2012/R2 use the the win8 drivers. There will be five different drivers in the folder.

You’ll need to install each of the drivers. Right click each .INF file and select install. Windows 8.1 made this easy. I searched *.INF in the folder, highlighted all five, right clicked, then clicked “Install”

Click “Yes” on all UAC prompts that appear, and click “Install” when asked to verify you really want to install the drivers.

Once the drivers have been successfully installed, you are now ready to shut the guest down.

Convert the disk image

You’ll need to convert the VHD or VHDX file into a format usable by KVM. I do believe that KVM has native support for VHDs, however, I like to run my VMs with the qcow2 format.

First, if the VM was running with a VHDX file, you’ll need to convert it to a VHD.

Edit: I’m not sure if the above is exactly true any more. It may be possible to use qemu-img to convert directly from VHDX to another format supported by KVM.

On your Hyper-V server, launch Powershell. Execute the following cmdlet:

This will convert your VHDX to a dynamic VHD. I chose a dynamic VHD to reduce the size of the image that has to be copied over. Refer to Microsoft’s documentation for more details on the Convert-VHD cmdlet.

Once you have a VHD, copy it to your KVM image store.

You can now convert the image. I like to use qcow2.

You will now have a disk image you can use to create your VM.

Create the VM

You are now free to create the VM using the freshly created image. Since the VirtIO drivers were installed, create the machine with a VirtIO NIC for best performance. With my Windows 8.1 test VM, I was unable to boot using a VirtIO disk. I was, however, able to boot using an SATA or an IDE disk.  Note, there may be reduced performance when not using VirtIO for the disk.

Click to share: Share on FacebookShare on Google+Share on RedditTweet about this on TwitterPin on Pinterest

Leave a Reply

Your email address will not be published. Required fields are marked *