Booting a Gen2 UEFI Disk2VHD VHDX Image in Hyper-V
I very often receive DISK2VHD exported files from other companies that we need to import to our systems for various reasons and whether we use partition software to convert to MBR the result is often that the VHDX simply loses all partitions.
The first step is always to take a copy of your original VHDX files and leave them safely in place.
Once you have your copy you can then test that it can be mounted in Windows 10 - if you can mount the system disk then the image is intact and you can progress:
Once you have mounted the disk you should be able to browse the contents of the Windows drive...
Now you need to your EFI partition fixed - it probably shows up as RAW as it is not decipherable by your foreign environment as it is a secured partition.
This happens because the EFI partition is secured to a single hardware ID and cannot be exported properly by Disk2VHD. We will need to remedy this if we are too successfully boot the VM in it's new environment.
In the below we can see that that there is a 100MB EFI partition ()you can't quite see this the RAW writing) but it is present. If you format this partition again, you can make it ready for use with the existing partition and boot your system:
Now you can detach the disk and make your VM - make sure to choose Gen2
Now boot the drive with a Windows 10 DVD ISO as the first boot and choose 'repair'
You must now enter troubleshooting and command prompt, where you must:
- Enter "diskpart" and press Return.
- Enter "list disk" and check that the system disk is disk 0
- Enter "sel disk 0" or another number if that is not the system disk.
- Enter "list vol" and press Return - note the drive letter of your Windows volume (most likely the largest option), as well as which volume says RAW next to it.
- Enter "sel vol #" where "#" is the number of the volume that says RAW next to it (this is the reason your VHDX doesn't "just work" when Disk2vhd has completed).
- Enter "format fs=FAT32" and press Return.
- Enter "assign letter=b" and press Return.
- Enter "exit" and press Return.
- Enter "bcdboot [systemdrive]:\windows /s b: /f UEFI" and press Return (where "[systemdrive]" is the drive letter of the Windows volume shown using the "list vol" command; "B" is the letter we assigned to the EFI System volume after formatting it to FAT32). (If you get an error here, try dropping the /f from this command)
- Now you have an intact EFI partition ready to boot to your system drive...
You should be able to see the system offered as able to boot by exiting the command prompt in the Windows RE environment and be able to boot directly.