0

I cannot make my VHD bootable.

I'm following this guild word for word, trying to create a Bootable VHD.

The BCDboot is supposed to create boot configuration entry so that windows bootloader can boot from the VHD, and I've seen it went successful, however, it just doesn't work:

D:>P:\windows\system32\bcdboot P:\windows /s P:
Boot files successfully created.

D:>BCDEdit

Windows Boot Manager

identifier {bootmgr} device partition=\Device\HarddiskVolume1 path \EFI\MICROSOFT\BOOT\BOOTMGFW.EFI description Windows Boot Manager locale en-US inherit {globalsettings} default {current} resumeobject {c605aeaf-...8} displayorder {current} toolsdisplayorder {memdiag} timeout 30

Windows Boot Loader

identifier {current} device partition=C: path \Windows\system32\winload.efi description Windows 10 locale en-US inherit {bootloadersettings} recoverysequence {c605aeb1-...8} displaymessageoverride Recovery recoveryenabled Yes isolatedcontext Yes allowedinmemorysettings 0x15000075 osdevice partition=C: systemroot \Windows resumeobject {c605aeaf-...8} nx OptIn bootmenupolicy Standard hypervisorlaunchtype Auto

I.e., the device partition=P: entry is not there. When I tried to boot it from Hyper-V, Hyper-V tells me that there is no boot-loader.

What could possibly wrong and how can I fix it? (again, I'm followed this guild word for word successfully until I came to the bcdboot & BCDEdit step. I.e., all my steps are exactly as shown there.)

UPDATE:

I'm not sure if I'm using UEFI though, because these are all it takes for me to create my disk:

select vdisk file=e:\vhd\winboot.vhd
attach vdisk
create partition primary
assign letter=v
active
format quick FS=NTFS Label=VHD

Most importanly, when select the Generation type for hyper-v, I chose Generation 1, which I think don't support UEFI.

xpt
  • 9,385
  • 44
  • 120
  • 178

2 Answers2

1

If you are using UEFI, you need to convert the attached VHD's partition table to GPT:

  1. Access WinPE Open Command Prompt
  2. Prepare the UEFI disk by creating three partitions via diskpart:
    diskpart
     select disk 0
     clean
     convert gpt
    

    rem == 1. System partition ========================= create partition efi size=100 format quick fs=fat32 label="System" assign letter="S"

    rem == 2. Microsoft Reserved (MSR) partition ======= create partition msr size=128

    rem == 3. Main partition =========================== create partition primary format quick fs=ntfs label="Main" assign letter="M"

    exit

  3. Add the entry in the boot menu with /f UEFI
JW0914
  • 9,096
wasif
  • 9,176
1

The tutorial followed left out the step for creating the boot partition, as well as WinRE:

  1. Create correct partition structure via DiskPart:
    1. It's simpler to clear the VHD's partition table and re-partition (VHD: disk 0):
      # Select disk and clear the partition table:
        Sel Dis 0
        Clean
      

      Create WinRE partition:

      Cre Par Pri Offset=1024 Size=665 Id=27 Format Quick Fs=ntfs Label=WinRE

      Create Boot partition:

      Cre Par Pri Size=100 Format Quick Fs=ntfs Label=Boot Active

      Create System partition:

      Cre Par Pri Format Quick Fs=ntfs Label=System

      Verify:

      Lis Par Lis Vol

      Exit

    2. If preserving existing data on the VHD's [OS] System partition:
      # Select disk and [OS] System partition:
        Sel Dis 0
        Sel Par 1
      

      Shrink System partition by 765MB [RAW]:

      Shrink Desired=765 Minimum=750 # WinRE: 665MB, min 650MB # WinRE partition must have 320MB free (WinRE.wim is ~300MB in size) # Boot: 100MB

      Create WinRE partition:

      Cre Par Pri Offset=1024 Size=665 Id=27 # If it fails, remove Offset=1024 Format Quick Fs=ntfs Label=WinRE

      Create Boot partition:

      Cre Par Pri Size=100 Format Quick Fs=ntfs Label=Boot Active

      Verify:

      Lis Par Lis Vol


  2. Configure boot partition:
    1. While booted to Windows in the VHD's VM:
      BCDboot C:\Windows /v
      
    2. From WinPE/WinRE:
      1. Boot the VHD's VM to WinPE via a Windows install ISO
      2. Open terminal via SHIFT+F10:
        BootRec /FixMBR && BootRec /FixBoot && BootRec /RebuildBCD
        
        /RebuildBCD may or may not find an OS, either is okay
      3. Reboot the VM

  3. Configure WinRE partition via this answer:
    • #2: If VHD doesn't have WinRE at C:\Recovery or %WinDir%\System32\Recovery\, copy the host's WinRE.wim to the VHD's %WinDir%\System32\Recovery\
    • #3: Skip (WinRE partition creation)
JW0914
  • 9,096