Solved Migrating from BIOS to EFI: not booting (Hyper-V VM)


I have a freebsd vm running as a Gen1 in Hyper-V (legacy BIOS boot) and am trying to migrate it to UEFI (Gen2).

I made a new disk with gpart: GPT, a partition for EFI, a swap, and a data partition where I copied my root.

I used gpart to write the EFI partition as well (gpart bootcode from liveCD /boot/boot1.efi).

Now I created a new VM (Gen2) with that disk, disabled secureboot, but it doesn't boot.
Hyper-V UEFI loader says it does not find an OS on the drive.

I tried booting on liveCD to check the partitions - they look fine - and write the bootcode again but to no avail.

Any idea of what I could have missed or done wrong?
Well there are two boot entries currently one that is supposed to be for the hard drive, which doesn't work, and once for the CD, which does.

Should I try and remove and recreate the first one manually with that tool? I am afraid the hypervisor will just overwrite this with its default stuff.
Dont know if it is relevant for your problem but, you aren't doing things right for setting the efi boot loader. The method you describe is dead since many times now and shouldn't be used anymore.

You have to "newfs_msdos" the efi partition, then create at least efi/boot directories and copy inside /boot/loader.efi as efi/boot/bootx64.efi.

Normally, your hypervisor should have this efi boot entry as default. No need to create one with efibootmgr. That said, I never used Hyper-V. Read well its documentation.