Tutorial: Migrate a Windows VM from vSphere to KVM

In this guide, we will migrate a Windows VM from vSphere to KVM.

Requirements

  • A vSphere VM with one of the following operating systems (All 64 bit):
    • Windows Server 2003
    • Windows Server 2008
    • Windows Server 2008 R2
    • Windows Server 2012
    • Windows Server 2012 R2
    • Windows 7
    • Windows 8
    • Windows 8.1
    • Windows XP
  • Administrator privileges for the VM.
  • The VM must only have one disk.

Step 1 – Clone the VM to be Migrated

Since we will modify the VM before converting formats, first clone the VM to keep the original VM intact.

migrate_windows1

Step 2 – Install Virtio Drivers

After cloning, power on the new VM. Download the Virtio drivers onto the machine running the vSphere client. Attach the ISO to the VM.

migrate_windows2

Open the Device Manager on the Windows VM. Then, right click on the root device and select “Add legacy hardware”.

migrate_windows3

Click Next. Then select “Install the hardware that I manually select…” and click Next.

migrate_windows4

Click Next again. Then, click “Have Disk…”.
Click “Browse…”.

migrate_windows5

Then, navigate to the directory of the ISO.

migrate_windows6

Click on “Balloon”. Then, select your operating system version.
Select the architecture (x86 or amd64). Then, select the INF file (There should only be one of these).
Click OK, then Next, and Next again. You may need to confirm the driver installation.

migrate_windows7

When installing the driver, you may receive an error saying that the device cannot start or is not working properly. This is normal, and the driver should be able to start when the VM boots on a KVM hypervisor.

Repeat the process above for the directories NetKVM, qemupciserial, viorng, vioscsi, vioserial, and viostor.

Ignore errors if the qemupciserial driver complains about the machine architecture.

Finally, install the QEMU guest agent on the VM. The installer is located in the ISO file.
Only use the installer that matches your architecture (x86 or x64).

migrate_windows8

Step 3 – Add the Virtio Drivers to the Windows Registry

Download the Virtio Registry File onto the VM.
Then, open the Windows Registry Editor by searching regedit from the start menu.
Click File -> Import…

migrate_windows9

Then select the Virtio Registry File that was downloaded.

Step 4 – Uninstall VMware Tools

From the control panel, click on “Uninstall a program”.

migrate_windows10

Fine the VMware Tools program. Right click on it and select Uninstall. Then, confirm the uninstall.

migrate_windows11

If prompted to reboot the machine, select Yes.

Step 5 – Install Cloudbase

Download the stable Cloudbase software.
Open the installer and click Next until the final the step is reached.
Select both the sysprep and the shutdown options. Then, click Finish.

migrate_windows12

Step 6 – Convert VMDK to QCOW2

Note the path of the hard disk of the VM by editing the settings of the VM and selecting the Virtual Disk.

migrate_windows13

Copy the flat VMDK from the ESX host to the Image Library, or a machine with the qemu-img command available.

migrate_windows14

After copying, convert the VMDK to a QCOW2 image.

[bash]qemu-img convert -O qcow2 <Input VMDK file> <Ouput QCOW2 file>[/bash]

For example:

[bash]qemu-img convert -O qcow2 pf9-win7-copy-flat.vmdk pf9-win7.qcow2[/bash]

Step 7 – Upload the Image to the Image Library Host

You can simply copy the converted qcow2 image to the Image library host’s image directory.

migrate_windows15 migrate_windows16

OR

Follow our support guide on Getting Started With The OpenStack Command Line if the openstack client is not yet installed.
Then, use the openstack command to upload the image.

[bash]openstack image create –disk-format qcow2
–container-format bare
–file pf9-win7.qcow2
–visibility public
–name pf9-win7
–property pf9_description=”Windows VM migrated from vSphere”
–property pf9_virtual_size=<Size in bytes>[/bash]

For example:

[bash]openstack image create –disk-format qcow2
–container-format bare
–file
–visibility public
–name
–property pf9_description=”Windows VM migrated from vSphere”
–property pf9_virtual_size=26422542336[/bash]

Step 8 – Create an Instance

Create an instance as you normally would. However, for Windows VMs using cloudbase-init, ensure cloud-init is enabled.

migrate_windows17

Enjoy your newly migrated Windows VM!

migrate_windows18

The browser you are using is outdated. For the best experience please download or update your browser to one of the following:

Learn the FinOps best practices to maximize your cloud usage & budget:Register Now
+