Converting Hyper-V to KVM



  • I had the time and spare disk space to export a copy of all my Hyper-V virtual machines to a NAS (Fedora 30 system with a public Samba share). So I took advantage of this to convert the system to KVM on Fedora 30.

    1. Shutdown the VM to be migrated. You need to ensure everything is in a consistent state.

    2. With Hyper-V Manager on your control system and then select each VM and choose Export.
      984b0022-cbc0-42e6-8d38-403bb702975d-image.png

    3. Enter the path to the location to store the export. In my case the samba share.
      9a1ee95c-f6ba-4bc3-a97d-3a99a4393bd4-image.png

    4. Make a note of the processor count, memory, and MAC (optional) of the systems you are going to export.
      81667a52-11c6-4f32-b629-22428451e035-image.png

    5. Repeat for all the VMs that you are moving

    6. Copy the vhdx of the exported VM to the KVM server. I dropped everything in the /var/lib/libvirt/images folder because that is the default folder KVM uses for disk images.
      Hyper-V exports things into a fixed structure of VM Name -> Virtual Hard Disks -> vhdx file.
      de2577b5-ad3e-4cdb-a15c-9ad2e733f6cd-image.png

    7. Install the package virt-v2v on your KVM host.

    dnf install -y virt-v2v
    
    ====================================================================================================================================
     Package                                 Architecture       Version                                       Repository           Size
    ====================================================================================================================================
    Installing:
     virt-v2v                                x86_64             1:1.40.2-4.fc30                               fedora              1.7 M
    Installing dependencies:
    .............more deps..........
    
    1. Now you can begin to convert the vhdx disks to qcow2 witth virt-v2v command.
    sudo virt-v2v -i disk /var/lib/libvirt/images/Naggaroth.vhdx -o local -of qcow2 -os /var/lib/libvirt/images/
    
    1. When is start sup you can see it opens the disk and loads a temp virtual machine to convert things.
      3892febd-d47b-4cac-9861-fcbaf4f0a9fc-image.png
      636e7885-715e-4139-8011-588a02bb2c0f-image.png

    2. Once it completes, do not just close your session. Make a note of the guest OS and boot type listed.
      21857940-d4ba-4277-acd7-bf26773a5e67-image.png

    3. You will see the converted vhdx named the same with -sda appended to the end. You can now delete the *.vhdx and *.vhdx.xml. I attempted to use the xml to import the VM, but it did not work. Likely jsut some setting needing changed or something. But I did not spend anytime troubleshooting it.
      027b19d1-22be-4553-bbdb-1517641eb5dd-image.png

    4. Create anew VM with Virtual Machine Manager.

    5. Choose Import existing disk image and click Forward.
      ca080973-5798-42f0-8980-9a23f6da0560-image.png

    6. Browse to the created *.vhdx-sda disk and also specify the OS correctly at the bottom of the dialog. Then click Forward.
      4aabdb17-0f59-4713-9194-f0844571b7ea-image.png

    7. Specify the same amount of memory as the system had in Hyper-V as well as the number of CPUs, then click Forward.
      5cdd89d5-dea6-4421-81d5-8d626cc9a35a-image.png

    8. Give the VM a name, click the checkbox to customize and setup the networking as desired (I like to use the macvtap, but whatever you want). Now click Finish.
      0664b941-875d-4590-a047-5dcbbf2bd4d1-image.png

    9. The details of the configuration opens automatically. If this is a UEFI install, you have to change the Firmware type from BIOS (default) to UEFI. Click Apply. If you have any other specific settings you want preserved (like MAC address), set them now. When your changes are complete, click Begin Installation at the top of the window.
      f98be945-9055-4473-a66d-a50992d7cf17-image.png

    10. It will only take a moment, and the VM will power on and boot. Assuming everything was successful, you will now have a working VM.
      efbe4485-f6dc-453c-b4ce-db85741d596e-image.png

    11. The first login will be briefly CPU intensive as the system updates itself.
      8e5ed029-c03b-4d5c-ac15-b3c082bad27c-image.png



  • The only Debian system I have failed to convert. It was only a test JitsiMeet install so not important, but I will take time later to see if I can make it convert.

    ae83180d-513b-4214-9cc7-5b5fa272a2ae-image.png



  • The v2v conversion seems limited to a single CPU.
    48093b6d-6d7c-48c9-98b0-0110932d753a-image.png



  • Is this a lab you've converted from Hyper-V to KVM or production (client and or business workloads, aka not production for your house).



  • qemu-img convert is what I've used before successfully.



  • @DustinB3403 said in Converting Hyper-V to KVM:

    Is this a lab you've converted from Hyper-V to KVM or production (client and or business workloads, aka not production for your house).

    This is my personal server I use to run various stuff as well as to run lab things.

    It was Hyper-V 2012R2 upgraded to Hyper-V 2016.

    Now it is KVM on Fedora 30.



  • @Obsolesce said in Converting Hyper-V to KVM:

    qemu-img convert is what I've used before successfully.

    I've had issues with that converting things. virt-v2v has worked better for me.



  • Everything converted, except the JitsiMeet instance. I did all of it via virt-amanger and ssh by way of ZeroTier (the 10.224.0.0/24 network is ZT).
    74d74d90-7585-4000-af85-c5a6e534b18e-image.png



  • pages on daerma.com load slow. No idea why, it is a basic WP site.

    obelist.daerma.com loads at what seems a normal pace.

    naggaroth.daerma.com doesn't seem to have any issues either.



  • Is all your linux VMs using virtio drivers for network?



  • @black3dynamite said in Converting Hyper-V to KVM:

    Is all your linux VMs using virtio drivers for network?

    Umm whatever virt-manager uses by default.



  • @black3dynamite said in Converting Hyper-V to KVM:

    Is all your linux VMs using virtio drivers for network?

    49ae84da-ff04-43ed-b7bb-afbb5a5662af-image.png



  • Comments and steps organized in initial post.



  • @JaredBusch said in Converting Hyper-V to KVM:

    pages on daerma.com load slow. No idea why, it is a basic WP site.

    Removed an old IP from the router, and it all works faster. That makes no sense. But it was something that needed cleaned up.