How To: Convert VHD-bootable Image into Hyper-V VM
Scenario
You have a VHD used to boot your PC or server (see [[Boot from VHD]]). You need to make this VHD bootable as Hyper-V VM.
Solution
This would not work by default. You will need to execute the following sequence of tasks.
Note: the following sample commands assume that you mount your VHD as disk F:
Turn off the VM (if was running) and mount VHD to some working OS (e.g. your host OS).
Run: bcdboot c:\windows /s f:
Run: bcdedit /store f:\Boot\bcd /set {bootmgr} device hd_partition=F:
Run: bcdedit /store f:\Boot\bcd /set {default} device hd_partition=F:
Run: bcdedit /store f:\Boot\bcd /set {default} osdevice hd_partition=F:
Load “System” registry hive from OS located in VHD (i.e. Regedit -> Load Hive -> select “F:\Windows\System32\Config\System”)
Change startup mode for “IntelIDE” driver from “3” to “0”. (That may be already the case depending on how you OS boots in Boot from VHD scenario).
Conclusion
Using this procedure you should be able to create a dual-boot system that works perfectly both when started with Boot from VHD on real hardware and in Hyper-V VM.