Migrating VM Disk from HyperV to Proxmox (qm importdisk) BOOT FAILED

tomstephens89

Renowned Member
Mar 10, 2014
177
6
83
Kingsclere, United Kingdom
Hi all, I am trying to migrate a 1.4TB HyperV VHDX disk from a Gen2 machine to a new proxmox server. I exported the VM in HyperV and copied it overnight to the proxmox box via SFTP/SSH. I then made a new proxmox VM with no disk then ran qm importdisk 101 /blabla/disk2import.vhdx local-lvm.

The import process ran and the disk imported. I then added it via the GUI but cannot boot from it. Not a bootable disk.

gdisk reports this for the new lv.

root@proxmox01:/etc# gdisk -l /dev/mapper/pve-vm--101--disk--0
GPT fdisk (gdisk) version 1.0.3

Partition table scan:
MBR: not present
BSD: not present
APM: not present
GPT: not present

Creating new GPT entries.
Disk /dev/mapper/pve-vm--101--disk--0: 3145728000 sectors, 1.5 TiB
Sector size (logical/physical): 512/512 bytes
Disk identifier (GUID): 22C09906-1120-442D-AA53-3CEFEEA0C302
Partition table holds up to 128 entries
Main partition table begins at sector 2 and ends at sector 33
First usable sector is 34, last usable sector is 3145727966
Partitions will be aligned on 2048-sector boundaries
Total free space is 3145727933 sectors (1.5 TiB)

Number Start (sector) End (sector) Size Code Name

Any ideas? It looks like there is no partition table anymore. The original HyperV VM is running Ubuntu Server.

EDIT:

gdisk on the original HyperV VM shows its a GPT disk, but changing the BIOS mode in proxmox does not make it boot and doesn't explain where the GPT partition table has gone?

tom@OSS-OWNCLOUD:~$ sudo gdisk -l /dev/sda
GPT fdisk (gdisk) version 1.0.1

Partition table scan:
MBR: protective
BSD: not present
APM: not present
GPT: present

Found valid GPT with protective MBR; using GPT.
Disk /dev/sda: 3145728000 sectors, 1.5 TiB
Logical sector size: 512 bytes
Disk identifier (GUID): E91119F7-B24F-4475-AAFD-AB141C00BB6D
Partition table holds up to 128 entries
First usable sector is 34, last usable sector is 3145727966
Partitions will be aligned on 2048-sector boundaries
Total free space is 4029 sectors (2.0 MiB)

Number Start (sector) End (sector) Size Code Name
1 2048 1050623 512.0 MiB EF00
2 1050624 2050047 488.0 MiB 8300
3 2050048 3145725951 1.5 TiB 8E00
 
Did you set your vm to be uefi?
On the hardware tab set BIOS to OMVF and add an EFI disk on the same page with the add button.
At the options tab make sure that the right disk is selected for the boot order.
 
Did you set your vm to be uefi?
On the hardware tab set BIOS to OMVF and add an EFI disk on the same page with the add button.
At the options tab make sure that the right disk is selected for the boot order.

Read above, yes I changed the BIOS mode. However the problem is that the qm importdisk command has left me with an LV that has no valid partition table at all. Also see above.
 
Could you check out the disk using a live cd of some sort?
I have never imported a vhdx file directly, all my converted imports went well though.
Code:
qemu-img convert -f vhdx image.vhdx -O raw image.raw
qm importdisk 102 image.raw local-zfs
These are the commands I use for importing vhd(x) files.
 
Last edited:
Could you check out the disk using a live cd of some sort?
I have never imported a vhdx file directly, all my converted imports went well though.
Code:
qemu-img convert -f vhdx image.vhdx -O raw image.raw
qm importdisk 102 image.raw local-zfs
These are the commands I use for importing vhd(x) files.

I used gdisk on proxmox directly and verified that the logical volume in local-lvm was indeed missing a valid partition table. The disk was supposed to be GPT, which it is as verified on the original server that I had to bring back up after this failed.

I imported the vhdx directly with qm importdisk as per a post by dietmar on here.

https://forum.proxmox.com/threads/converting-vhdx-to-raw.36354/post-178353

I am planning to do the migration at application level already by moving files and databases but I might try once more but with qemu-img convert first.
 
So I am getting closer. Converting from VHDX to RAW then importing has preserved the GPT partition table.

Now how to make the VM to a UEFI boot to this GPT disk? Whats the EFI disk in the GUI for?


root@proxmox01:/mnt/convert# gdisk -l /dev/pve/vm-101-disk-0
GPT fdisk (gdisk) version 1.0.3

Partition table scan:
MBR: protective
BSD: not present
APM: not present
GPT: present

Found valid GPT with protective MBR; using GPT.
Disk /dev/pve/vm-101-disk-0: 3145728000 sectors, 1.5 TiB
Sector size (logical/physical): 512/512 bytes
Disk identifier (GUID): E91119F7-B24F-4475-AAFD-AB141C00BB6D
Partition table holds up to 128 entries
Main partition table begins at sector 2 and ends at sector 33
First usable sector is 34, last usable sector is 3145727966
Partitions will be aligned on 2048-sector boundaries
Total free space is 4029 sectors (2.0 MiB)

Number Start (sector) End (sector) Size Code Name
1 2048 1050623 512.0 MiB EF00
2 1050624 2050047 488.0 MiB 8300
3 2050048 3145725951 1.5 TiB 8E00
 
UPDATE!

I have solved this. I added an EFI disk to store EFI boot info, changed BIOS to OVMF, added an EFI boot option in the BIOS to look at the ubuntu grub64 loader and it boots.

Thanks all!

Process for migrating a GPT formatted Gen2 HyperV VHDX is as follows:

1. Export the VM from HyperV, copy the VHDX file to Proxmox host storage.
2. Convert VHDX to RAW: qemu-img convert -f vhdx OSS-OWNCLOUD.vhdx -O raw /mnt/convert/occonverted.raw
3. Make a new VM, use its ID in the import disk command: qm importdisk 101 occonverted.raw local-lvm
4. Attach the disk to VM, also add an EFI Disk. Change BIOS mode to OVMF.
5. In OVMF BIOS, add an EFI boot entry to point to the efi loader on the disk.
6. Boot.
 
How do I save my EFI boot information to the EFI disk so it is not lost on a reset of the VM?

EDIT: Looks like as long as the VM has an 'EFI Disk' and the EFI options are saved then this works. Note that if you detatch the EFI disk and reattach, it doesn't list as an 'EFI Disk'. Perhaps this is why my settings got lost just now.
 
Last edited:
Nice! Glad you got it to work.
AFAIK it doesn't matter if the EFI disk gets lost since it's just a boot firmware and contains vars like boot order.
I did a quick test by copying an existing vm with uefi and deleting the EFI disk. The vm booted after recreating the EFI disk and even without one.
I did some digging and it seems Proxmox will set a temporary EFI disk when booting without one:
https://forum.proxmox.com/threads/purpose-of-the-efi-disk.53862/
 
This guide has been useful for me two years later on PXE 7.2, thank you!
2. I didn't need this step, I just ran the qm importdisk directly on the vhdx.
5. Instructions here: https://pve.proxmox.com/wiki/OVMF/UEFI_Boot_Entries

I also need to disable Secure Boot, otherwise I got an access denied: Hit escape when you see the Proxmox logo on boot. Then Device Manager -> Secure Boot Configuration Make sure Attempt Secure Boot is disabled. If not, disable it and restart system.
Thanks!
 
  • Like
Reactions: PsYcRo

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!