The problem
An imported Gen2 Hyper-V VM won't boot. You get an EFI Shell or you are just stuck in the boot sequence.
When you go into the UEFI BIOS (press ESC during startup of the VM) you are able to make modifications and boot from a file. This works, but you are not able to save changes made in the BIOS. After shutting off the VM, the changes are lost and the VM doesn't boot anymore.
Others topics on this forum about this issue
There are several topics about this issue on this forum. It seems that it is somekind of general issue with the way Microsoft creates the Generation 2 UEFI boot partition. Maybe related to secure boot options Microsoft added to the Gen config (however, in my case Secure Boot was disabled in the Hyper-V config).
These are the topics I've found during my efforts to solve the issue:
Make a new disk, make partition, rsync data and so on:
https://forum.proxmox.com/threads/ubuntu-vm-efi-boot-problem.28318/
A long how-to for Windows Gen2 VM's, I didn't even try this one haha:
https://forum.proxmox.com/threads/hyper-v-gen-2-windows-guest-conversion.38954/
A solution with disk cloning with Clonezilla and an EFI disk:
https://forum.proxmox.com/threads/hyper-v-gen2-linux-to-proxmox.42865/
These 3 topics do offer solutions, but they are not easy to perform and can take a long time. For live-servers that shouldn't be down for a long time, this can be very inconvenient.
My solution
I've spend hours to solve this issue and tried the solutions offered in the topics I mentioned above. It took ages and maybe I did not perform any step right, but I had limited success.
Until, I tried to proceed experimenting with adding an EFI disk to the troubled VM! The topic where Clonezilla was used to sync data mentioned added the EFI disk already and at first I was a bit puzzled how it worked.
The EFI disk is a seperate (standalone) disk with only the EFI software on it. First I thought I have to size the disk and make a sda partition on it (more or less like Hyper-V does), but this solution works differently. Just add the disk and don't touch it anymore.
Adding a new EFI disk to the VM causes to overrule the not working EFI partition on the converted harddisk! It enables you to save the changes you've made in the BIOS, allowing you to boot from an EFI file that resides on the converted harddisk.
Steps needed to make it work
This is the important section of my topic!
Important! I did not test this with troubled Windows OS Gen2 VM's, but below worked well for my Ubuntu Gen2 VM's. Please feel free to add your experiences with Windows versions in this topic.
Note: I use Proxmox 5.2
An imported Gen2 Hyper-V VM won't boot. You get an EFI Shell or you are just stuck in the boot sequence.
When you go into the UEFI BIOS (press ESC during startup of the VM) you are able to make modifications and boot from a file. This works, but you are not able to save changes made in the BIOS. After shutting off the VM, the changes are lost and the VM doesn't boot anymore.
Others topics on this forum about this issue
There are several topics about this issue on this forum. It seems that it is somekind of general issue with the way Microsoft creates the Generation 2 UEFI boot partition. Maybe related to secure boot options Microsoft added to the Gen config (however, in my case Secure Boot was disabled in the Hyper-V config).
These are the topics I've found during my efforts to solve the issue:
Make a new disk, make partition, rsync data and so on:
https://forum.proxmox.com/threads/ubuntu-vm-efi-boot-problem.28318/
A long how-to for Windows Gen2 VM's, I didn't even try this one haha:
https://forum.proxmox.com/threads/hyper-v-gen-2-windows-guest-conversion.38954/
A solution with disk cloning with Clonezilla and an EFI disk:
https://forum.proxmox.com/threads/hyper-v-gen2-linux-to-proxmox.42865/
These 3 topics do offer solutions, but they are not easy to perform and can take a long time. For live-servers that shouldn't be down for a long time, this can be very inconvenient.
My solution
I've spend hours to solve this issue and tried the solutions offered in the topics I mentioned above. It took ages and maybe I did not perform any step right, but I had limited success.
Until, I tried to proceed experimenting with adding an EFI disk to the troubled VM! The topic where Clonezilla was used to sync data mentioned added the EFI disk already and at first I was a bit puzzled how it worked.
The EFI disk is a seperate (standalone) disk with only the EFI software on it. First I thought I have to size the disk and make a sda partition on it (more or less like Hyper-V does), but this solution works differently. Just add the disk and don't touch it anymore.
Adding a new EFI disk to the VM causes to overrule the not working EFI partition on the converted harddisk! It enables you to save the changes you've made in the BIOS, allowing you to boot from an EFI file that resides on the converted harddisk.
Steps needed to make it work
This is the important section of my topic!
Important! I did not test this with troubled Windows OS Gen2 VM's, but below worked well for my Ubuntu Gen2 VM's. Please feel free to add your experiences with Windows versions in this topic.
- Create a VM in Proxmox like you normally do including a harddisk on 'local'
- Change the BIOS to OVMF (UEFI) in the Options section
- Add an EFI disk to that same VM on 'local'
- Convert your .vdhx disk to .qcow2 with the qemu-img tool (alternatively you can use the qm importdisk command line if you prefer that)
- Overwrite the empty created .cqow drive Proxmox created with the qcow2 disk you just converted (example: /var/lib/vz/images/111/vm-111-disk-1.qcow2)
- Boot the VM
- Connect to the Console of the VM and press ESC immediately. You are now in the BIOS
- Go to 'Boot Maintenance Manager'
- Go to 'Boot Option'
- Go to 'Add Boot Option'
- Press enter on the 'PciRoot' volume
- Select EFI and press enter
- Select the folder of your OS (in my case it was 'ubuntu') and press enter
- Select the EFI file (in my case it was shimx64.efi) and press enter
- Fill out a description at 'Input the description' (I called it 'Boot From File')
- Press F10 to save (just to be sure)
- Go to 'Commit Changes and Exit'
- Select 'Change Boot Order'
- Press enter to get the blue pop-up
- Go to 'Boot From File' option (or the name you filled out at step 15)
- Press + until this boot option is on top of the list and press enter
- Press F10 to save (just to be sure)
- Select 'Commit Changes and Exit'
- Exit and voila, your VM boots!
Note: I use Proxmox 5.2
Last edited: