Virtualization is the best option for efficient hardware resource utilization. The most commonly used Hyper-V and Proxmox VE are good virtualization platforms but use different disk formats. Hyper-V relies on VHD/VHDX, while Proxmox VE operates with QCOW2 or raw disk formats in QEMU. These differences make the VM migration task more challenging. You need to first convert the virtual machine files before running on Proxmox VE.
In this article, we will demonstrate how to migrate VMs from Hyper-V to Proxmox VE. In addition, we will also show you how to convert or transform VM files in a compatible format after transferring on Proxmox VE.
Migrating VMs from Hyper-V to Proxmox VE
You need to perform the following steps to migrate VMs from Hyper-V to Proxmox VE:Step 1: Export Hyper-V Virtual Machine using PowerShell
In this step, we are using Powershell to export the Hyper-V virtual machine, you can also use the graphical method. First, Click on Start Menu on Windows. Type PowerShell in the search bar. Now, Right-click on the PowerShell option and click on “Run as Administrator”.
Now, perform the following steps to export the Hyper-V virtual machine. Before exporting, check which VMs are available on Hyper-V by running:
> Get-VM
The ‘Get-VM’ lists all VMs along with their status running on your machine.
Set VM Name and Export Path
Now, you will select the VM that you want to export from your machine. For example, in the above list, we are exporting Windows 11 virtual machines. To export Windows 11 VM, use the following PowerShell commands:
$VMName = "VM-Name" $ExportPath = "C:\Exports\$VMName"
Set your VM name as Windows 11 that you want to export and define the export folder path.
$VMName = "Windows 11" $ExportPath = "C:\Exports\$VMName"
Create the Export Directory
Before exporting files, first, you need to ensure the directory exists before exporting. Use the following command to check whether the exports directory exists or not:
> New-Item -ItemType Directory -Path $ExportPath -Force
Export the Windows 11 VM
Export the VM from Hyper-V using the below command:
> Export-VM -Name $VMName -Path $ExportPath
After running the above command, it shows an export progress bar on the PowerShell screen like the above.
Check the Exported Files
After the export is complete, use the following command to verify that the export files exist:
> Get-ChildItem -Path $ExportPath
Step 2: Transfer the Exported VM to the Proxmox Host
Once you successfully export your VM, you will move the files to your Proxmox VE server. If you need to transfer the file to your Proxmox host remotely, you can use the WinSCP tool for the process. Using the WinSCP tool, you can download large files using multiple SFTP connections and support OpenSSH certificates for host verification.
If you are using Proxmox on the remote machine use the SCP tool command in PowerShell:
> scp -r C:\Exports\$VMName root@ProxmoxIP:/var/lib/path/
In the above command, you just need to replace the ProxmoxIP with your Proxmox server’s IP address and path.
Step 3: Validate the File Integrity on Proxmox VE
After transferring the file to the Proxmox host, you can verify its integrity by running the following command on the Proxmox VE Shell page: # qemu-img check -r all "/root/VMtest/Virtual Hard Disks/Hyper-v-proxmox.vhdx"
Make sure to replace the file path with the correct one on your Proxmox host.
Step 4: Convert the VHDX Image to QCOW2 Format
To create a new virtual machine and convert the VHDX virtual hard disk image to the QCOW2 format, use this command:
# qemu-img convert -O qcow2 "/root/VMtest/Virtual Hard Disks/Hyper-v-proxmox.vhdx" /mnt/pve/NFS-test/images/107/vm-107-disk-1.qcow2
This command will convert the VHDX file to the QCOW2 format, suitable for use in Proxmox VE.
Step 5: Rescan the Storage to Recognize the Converted QCOW2 File
After converting the VHDX file to QCOW2, use the following command to refresh the storage scan of Proxmox and recognize the new file:
# qm rescan
Step 6: Add the Converted QCOW2 File to the Virtual Machine
To attach the converted QCOW2 disk to a newly created virtual machine, use the “qm set” command. For example, if you created a virtual machine with the ID 109, run:
# qm set 109 -scsi0 NFS-test:107/vm-107-disk-1.qcow2
The above command will add the new QCOW2 disk as the primary hard disk for the VM.
Step 7: Verify the Virtual Machine’s Disk and Start the VM
After adding the new QCOW2 disk, check the VM’s hard disk to ensure it’s been updated. You can now attempt to start the virtual machine to confirm that everything is working properly.
Conclusion
Migrating virtual machines from Hyper-V to Proxmox VE allows you to leverage Proxmox’s open-source flexibility and powerful features. While this guide outlines the general steps for migration, it’s important to keep in mind that the process may differ based on your specific virtual machine settings and host configurations. Always remember to back up your data and thoroughly test the setup to ensure a smooth migration.