How-to: fix non-booting (Linux) VM imported from a Gen2 VM Hyper-V source.

GuiltyNL

Well-Known Member
Jun 28, 2018
41
15
48
Rotterdam
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. :D

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.

  1. Create a VM in Proxmox like you normally do including a harddisk on 'local'
  2. Change the BIOS to OVMF (UEFI) in the Options section
  3. Add an EFI disk to that same VM on 'local'
  4. Convert your .vdhx disk to .qcow2 with the qemu-img tool (alternatively you can use the qm importdisk command line if you prefer that)
  5. 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)
  6. Boot the VM
  7. Connect to the Console of the VM and press ESC immediately. You are now in the BIOS
  8. Go to 'Boot Maintenance Manager'
  9. Go to 'Boot Option'
  10. Go to 'Add Boot Option'
  11. Press enter on the 'PciRoot' volume
  12. Select EFI and press enter
  13. Select the folder of your OS (in my case it was 'ubuntu') and press enter
  14. Select the EFI file (in my case it was shimx64.efi) and press enter
  15. Fill out a description at 'Input the description' (I called it 'Boot From File')
  16. Press F10 to save (just to be sure)
  17. Go to 'Commit Changes and Exit'
  18. Select 'Change Boot Order'
  19. Press enter to get the blue pop-up
  20. Go to 'Boot From File' option (or the name you filled out at step 15)
  21. Press + until this boot option is on top of the list and press enter
  22. Press F10 to save (just to be sure)
  23. Select 'Commit Changes and Exit'
  24. Exit and voila, your VM boots!
Cheers!

Note: I use Proxmox 5.2
 
Last edited:
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 effords 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. :D

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.

  1. Create a VM in Proxmox like you normally do including a harddisk on 'local'
  2. Change the BIOS to OVMF (UEFI) in the Options section
  3. Add an EFI disk to that same VM on 'local'
  4. Convert your .vdhx disk to .qcow2 with the qemu-img tool (alternatively you can use the qm importdisk command line if you prefer that)
  5. 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)
  6. Boot the VM
  7. Connect to the Console of the VM and press ESC immediately. You are now in the BIOS
  8. Go to 'Boot Maintenance Manager'
  9. Go to 'Boot Option'
  10. Go to 'Add Boot Option'
  11. Press enter on the 'PciRoot' volume
  12. Select EFI and press enter
  13. Select the folder of your OS (in my case it was 'ubuntu') and press enter
  14. Select the EFI file (in my case it was shimx64.efi) and press enter
  15. Fill out a description at 'Input the description' (I called it 'Boot From File')
  16. Press F10 to save (just to be sure)
  17. Go to 'Commit Changes and Exit'
  18. Select 'Change Boot Order'
  19. Press enter to get the blue pop-up
  20. Go to 'Boot From File' option (or the name you filled out at step 15)
  21. Press + until this boot option is on top of the list and press enter
  22. Press F10 to save (just to be sure)
  23. Select 'Commit Changes and Exit'
  24. Exit and voila, your VM boots!
Cheers!

Note: I use Proxmox 5.2
Thanks sooo much for this! My nested hyper-v virtualization just stopped working with the recent PVE 5.3 updates so I gave in and tried moving the VMs over but I couldn't get them to boot at all until I found this. So ymmv but I can confirm that these steps work for Windows Server 2016 Datacenter for me.
 
  • Like
Reactions: GuiltyNL
If you ever find yourself in St. Louis, MO I will take you to a local brewery and buy you a beer or 4! This was a lifesaver for me. I recovered a Hyper-V VM into a new proxmox cluster but had to correct the boot. The recovery worked but I had to start at step 7 to get my VM (Ubuntu as well) to boot. Thanks a bunch!!
 
  • Like
Reactions: GuiltyNL
  1. Create a VM in Proxmox like you normally do including a harddisk on 'local'
  2. Change the BIOS to OVMF (UEFI) in the Options section
  3. Add an EFI disk to that same VM on 'local'
  4. Convert your .vdhx disk to .qcow2 with the qemu-img tool (alternatively you can use the qm importdisk command line if you prefer that)
  5. 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)
  6. Boot the VM
  7. Connect to the Console of the VM and press ESC immediately. You are now in the BIOS
  8. Go to 'Boot Maintenance Manager'
  9. Go to 'Boot Option'
  10. Go to 'Add Boot Option'
  11. Press enter on the 'PciRoot' volume
  12. Select EFI and press enter
  13. Select the folder of your OS (in my case it was 'ubuntu') and press enter
  14. Select the EFI file (in my case it was shimx64.efi) and press enter
  15. Fill out a description at 'Input the description' (I called it 'Boot From File')
  16. Press F10 to save (just to be sure)
  17. Go to 'Commit Changes and Exit'
  18. Select 'Change Boot Order'
  19. Press enter to get the blue pop-up
  20. Go to 'Boot From File' option (or the name you filled out at step 15)
  21. Press + until this boot option is on top of the list and press enter
  22. Press F10 to save (just to be sure)
  23. Select 'Commit Changes and Exit'
  24. Exit and voila, your VM boots!
Cheers!

Note: I use Proxmox 5.2
Thanks, but you lost me at step 4 & 5?
 

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!