Skip to content

Migrating a Hyper-V VM to Proxmox (without 3rd party products)

Overview

This guide will show you how to migrate a Hyper-V VM to a Proxmox host without using 3rd party products like Starwinds V2V.

Procedure

1. Stop the Hyper-V VM

Stop your Hyper-V VM that you would like to migrate, either through the Hyper-V management UI or PowerShell:

Terminal window
# Get the VMs on the host
PS C:\> Get-VM
Name State CPUUsage(%) MemoryAssigned(M) Uptime Status Version
---- ----- ----------- ----------------- ------ ------ -------
vm-needs-migration Running 3 4096 21.15:00:19.2640000 Operating normally 10.0
# Stop the VM in question
PS C:\> Stop-VM -Name "vm-needs-migration"
# Confirm VM has not been auto-restarted
PS C:\> Get-VM
Name State CPUUsage(%) MemoryAssigned(M) Uptime Status Version
---- ----- ----------- ----------------- ------ ------ -------
vm-needs-migration Off 0 0 00:00:00 Operating normally 10.0

2. Locate the VM’s attached disks

Find the path of the VM’s attached disks:

Terminal window
# Find the VHDX path of the VM disk
PS C:\> Get-VMHardDiskDrive -VMName "vm-needs-migration" | select Path
Path
----
V:\Hyper-V\Virtual Hard Disks\vm-needs-migration.vhdx

3. Move the VM disk to the Proxmox host

Terminal window
# Move the VM disk to Proxmox
PS C:\> scp "V:\Hyper-V\Virtual Hard Disks\vm-needs-migration.vhdx" root@proxmox:/tmp/
root@proxmox's password:
vm-needs-migration.vhdx 100% 8292MB 73.5MB/s 01:52

4. Create the VM in Proxmox and import the VHDX

Terminal window
# Verify VM disk is present
root@proxmox:~# ls /tmp
...
vm-needs-migration.vhdx
...
# Import disk to VM
# Replace <your vm id> with the ID of the VM that is taking the disk
# Replace <your storage> with your storage pool
root@proxmox:~# qm importdisk <your vm id> /tmp/vm-needs-migration.vhdx <your storage>
importing disk '/tmp/vm-needs-migration.vhdx' to VM 132 ...
transferred 0.0 B of 60.0 GiB (0.00%)
...
transferred 60.0 GiB of 60.0 GiB (100.00%)
unused0: successfully imported disk 'vm_storage_pool:vm-132-disk-1'

Then, in the Proxmox UI:

  • Add the unused disk to your VM (Hardware > Unused Disk <number>)
  • Enable the disk for booting (if it’s a bootable disk) in the VM options (Options > Boot Order)
  • Boot the VM

5. Troubleshooting

If the VM does not boot because it was a Generation 2 Hyper-V VM, the EFI boot variables did not come over with the disk. They can be re-added through the VM’s UEFI BIOS settings.

EFI Issue

To recover the boot entry:

  1. Press any key to enter the UEFI BIOS
  2. Navigate to Boot Maintenance Manager
  3. Navigate to Boot Options
  4. Navigate to Add Boot Option
  5. Navigate to your boot disk
  6. Navigate to <EFI>
  7. Choose your distribution’s folder. Options vary by bootloader and operating system - for this example we’ll assume Debian. Navigate to <debian>.
  8. Select shimx64.efi if it exists (otherwise grubx64.efi)
  9. Give it a name - Debian is fine
  10. Select Commit Changes and Exit
  11. Select Change Boot Order
  12. Press Enter on the row showing Debian and <UEFI QEMU HARDDISK>, select the Debian option, press + to move it to the top, then press Enter
  13. Select Commit Changes and Exit
  14. Press Esc
  15. Press F10 to save, then Y to confirm
  16. Reset the VM, or return to the previous menu and select Reset

You should now reach the GRUB bootloader and be able to boot into Debian.