Documentation on Converting KVM QCOW2 Virtual Machine Disks into Importable Hyper-V VHDX Format
Converting a KVM qcow2 virtual machine to VHDX format for Hyper-V import requires more than just running qemu-img convert
. There's a critical kernel driver issue that must be addressed first. When you simply convert the disk format without preparing the Linux VM, it will fail to boot in Hyper-V because the initramfs lacks the necessary Hyper-V drivers.
This guide provides the complete process to prepare your Linux VM and successfully convert it for Hyper-V.
- A running KVM Linux virtual machine with qcow2 disk format
- Root access to the Linux VM
- QEMU tools installed on the host system
- Sufficient disk space for the conversion process
Important: These steps must be performed INSIDE the running Linux VM before conversion. Skipping this phase will result in a non-bootable VM in Hyper-V.
sudo tee /etc/dracut.conf.d/hyperv.conf >/dev/null <<'EOF'
add_drivers+=" hv_vmbus hv_storvsc hv_netvsc hv_utils "
hostonly="no"
EOF
This tells dracut to always include the Hyper-V bus, storage, and network drivers in the initramfs, and not to restrict to just the current host's drivers.
sudo dracut -f --kver "$(uname -r)"
This usually takes 15–45 seconds and regenerates /boot/initramfs-<your-kernel>.img
with those Hyper-V modules baked in.
ls -lh /boot/initramfs-$(uname -r).img
→ Should see a 50–100 MB file.
Make sure you're using UUID= entries (Hyper-V uses /dev/sdX
rather than /dev/vdX
):
cat /etc/fstab
blkid # to get UUIDs if needed
sudo shutdown -h now
Now that the VM is prepared, convert the qcow2 disk to VHDX format:
# Typical locations:
# /var/lib/libvirt/images/
# /home/user/VMs/
ls -lh /path/to/your-vm.qcow2
qemu-img convert -f qcow2 -O vhdx /path/to/your-vm.qcow2 /path/to/output/your-vm.vhdx
Options:
-f qcow2
: Source format-O vhdx
: Output format- Add
-p
for progress indicator on large disks
qemu-img info /path/to/output/your-vm.vhdx
Transfer the .vhdx
file to your Windows machine where Hyper-V is installed.
- Open Hyper-V Manager
- Click "New" → "Virtual Machine"
- Follow the wizard:
- Choose "Generation 1" for better compatibility
- Assign appropriate memory
- Use existing virtual hard disk: select your converted
.vhdx
file - Configure network adapter
- Integration Services: Enable all available services
- Network Adapter: Configure for your network setup
- Memory: Consider enabling Dynamic Memory if appropriate
- Processor: Assign appropriate CPU count
- Start the VM
- Verify network connectivity
- Check that all hardware is detected properly
- Install/update Hyper-V Integration Services if needed
- Cause: Initramfs missing Hyper-V drivers
- Solution: Go back to Phase 1 and ensure dracut configuration is correct
- Cause: Missing
hv_netvsc
driver - Solution: Verify the dracut config includes
hv_netvsc
and rebuild initramfs
- Cause: Missing
hv_storvsc
driver or wrong device names in fstab - Solution: Check dracut config and ensure fstab uses UUIDs
- Cause: Integration Services not properly installed
- Solution: Install/update Hyper-V Integration Services in the guest
- Backup: Always backup your original qcow2 file before conversion
- Testing: Test the converted VM thoroughly before decommissioning the original
- Integration Services: Install the latest Hyper-V Integration Services for optimal performance
- Snapshots: Consider taking a checkpoint immediately after successful conversion
This process has been tested with:
- RHEL/CentOS 7/8/9
- Ubuntu 18.04/20.04/22.04/24.04
- Fedora 35+
- Debian 10/11/12
Other systemd-based distributions using dracut should work similarly.