Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save nosmall/d9cba49b1d8c8b05059a35f5248f6707 to your computer and use it in GitHub Desktop.
Save nosmall/d9cba49b1d8c8b05059a35f5248f6707 to your computer and use it in GitHub Desktop.
Migrating Linux VMs from Proxmox VE to Hyper-V

Migrating Linux VMs from Proxmox VE to Hyper-V

This guide summarizes the complete process for migrating Linux virtual machines (e.g. Ubuntu) from Proxmox to Microsoft Hyper-V. Includes VM preparation, disk conversion and final setup.


## Phase 1: Preparing VM in Proxmox (Pre-migration) 🔧

Proper preparation is crucial for smooth transition and minimizing post-migration issues.

  1. a) Backup: Create complete VM backup.
  2. b) Log in as root
    sudo su
  3. System update:
    apt update && apt upgrade -y
  4. Remove Proxmox tools:
    apt-get purge qemu-guest-agent
  5. Install Hyper-V tools (LIS): These packages contain network and storage drivers for Hyper-V.
    apt-get install linux-virtual linux-cloud-tools-virtual linux-tools-virtual
  6. Proactive network fix (Netplan): Prepare network configuration to work in both Proxmox and Hyper-V.
    • Check current interface: ip a (e.g. ens18)
    • Find config file: ls /etc/netplan/ (e.g. 50-cloud-init.yaml)
    • Edit file (nano /etc/netplan/50-cloud-init.yaml) and add section for eth0 (typical name in Hyper-V):
      network:
        version: 2
        ethernets:
          ens18:      # Original name in Proxmox
            dhcp4: true
          eth0:       # New name for Hyper-V
            dhcp4: true
    • Apply changes (only ens18 will be active in Proxmox):
      netplan apply
  7. Shut down VM in Proxmox.

## Phase 2: Disk Identification and Conversion 💿

Now we'll convert VM disk to Hyper-V format (VHDX).

  1. Login to Proxmox server via SSH.

  2. Find your VM ID and config (replace 101 with your VMID):

    qm config 101
  3. Find disk definition line, e.g.: scsi0: nvme4tb:vm-101-disk-0,iothread=1,size=80G

    • Here storage is nvme4tb and disk name is vm-101-disk-0.
  4. Find exact disk path. Path varies by storage type (Directory, LVM, ZFS). For ZFS:

    ls -l /dev/zvol/*/* | grep vm-101-disk-0
    • Correct path will be e.g. /dev/zvol/nvme4tb/vm-101-disk-0.
  5. Start disk conversion using qemu-img. Use -p for progress.

    • Replace disk path and destination path for VHDX file.
    • For ZFS/LVM source format (-f) is always raw.
    qemu-img convert -p -f raw -O vhdx /dev/zvol/nvme4tb/vm-101-disk-0 -o subformat=dynamic /mnt/nvme1tb/dump/vm-101-disk-0.vhdx

## Phase 3: Creating VM in Hyper-V 🖥️

With VHDX file ready, create new VM in Hyper-V.

  1. Move .vhdx file to Hyper-V server.
  2. Open Hyper-V Manager and select Action -> New -> Virtual Machine.
  3. Enter name and continue.
  4. Select correct generation based on Proxmox config:
    • Generation 1: For BIOS boot (older VMs)
    • Generation 2: For UEFI boot (modern VMs)
    • To check boot mode in Proxmox:
      • For UEFI: VM config must have efidisk0 or bios: ovmf
      • For BIOS: If these are missing, it's BIOS boot
    • Alternative check inside VM:
      [ -d /sys/firmware/efi ] && echo "UEFI" || echo "BIOS"
  5. Allocate memory and select virtual switch in Configure Networking.
  6. In Connect Virtual Hard Disk select Use existing virtual hard disk and choose your converted .vhdx.
  7. Before first start, right-click VM, select Settings.
  8. In Security section, disable Enable Secure Boot.
  9. Start VM.

## Phase 4: Verification and Completion ✅

Final step is to verify everything works correctly.

  1. Connect to console of new VM in Hyper-V.
  2. Verify network connection. Thanks to step 1.5 it should work automatically.
    ip a
    ping 8.8.8.8
  3. Check all your services and applications are running correctly.
  4. (Optional) Try shutting down VM, re-enable Secure Boot in settings and verify system boots.
  5. After thorough testing you can delete original VM from Proxmox to free space.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment