How to repair a BCD store on the EFI partition

By: Frank Rysanek [ rysanek AT fccps DOT cz ]

Restoring a backup of Windows 8 / 8.1 using Ghost 11.5.1 or so, right?
Interestingly, restoring the BCD store (file) from a backup is not enough to restore the system's ability to boot. The BCD file needs some further fine-tuning, that wasn't needed with previous Windows versions...

Note that you need to carry out the following procedure right in the target machine. Unfortunately it seems that you cannot correct the BCD in another PC. Not sure why, possibly due to some UEFI crypto black magic.

You may have to face (and switch between) two booting methods, in your machine's "BIOS Setup":

  1. UEFI boot for the Windows 8 install on your hard drive (now likely unbootable)
  2. legacy BIOS boot for the USB thumb drive with Windows PE and Ghost

Boot WinPE x86 or amd64 as appropriate.
You'll get drive letters assigned approximately thusly (see `mountvol`):

C: = Windows system volume (now possibly unbootable, but accessible via WinPE)
X: = Windows PE system volume (ramdisk, ephemeral)
D: = Windows PE bootable USB thumb drive (can be hot-plugged at runtime)
E: = CD/DVD drive

To repair the 'BCD store', you need to have access to that file.
The trouble is, that on machines booting via EFI (EFI boot is the only option starting from Win8_64) the BCD store is located on a dedicated EFI partition, which is hidden from Windows and cannot even be mounted using mountvol.
But, you can mount it via diskpart:

C:> diskpart
DISKPART> list disk
DISKPART> list partition
DISKPART> select disk <N>        ; (possibly select disk 0, 0-based)
DISKPART> select partition <M>   ; (possibly select partition 1, 1-based)
DISKPART> assign                 ; (mount current part to a free letter)
DISKPART> list volume
DISKPART> exit

(Hey, don't mess with the EFI partition's attributes!)

Now... suppose that DISKPART mounted the EFI partition to letter F:
Check that F:\EFI\Microsoft\Boot\BCD exists.
The file is hidden - try 'dir /a:hs' if you don't have a proper file manager in your WinPE.
If the BCD file exists, make a backup (manual copy) of that file.
Possibly look around (in the same directory) for previous backups, in case you wanted to restore those.

Next, you need to tell bcdedit (using /store ), that the BCD store to work upon, is on the F: partition - and do the rest as usual.

C:> bcdedit /store F:\EFI\Microsoft\Boot\BCD /set {default} device partition=c:
C:> bcdedit /store F:\EFI\Microsoft\Boot\BCD /set {default} osdevice partition=c:
C:> bcdedit /store F:\EFI\Microsoft\Boot\BCD /set {bootmgr} device partition=c:

Now you can reboot the PC - by exiting from the WinPE default shell (cmd.exe):

C:> exit

Pull the USB thumb drive with WinPE...
What? It doesn't boot Windows 8!
***Sigh*** Relax... Remember to go into the BIOS Setup and flip back to UEFI booting.

Further reading:
How to create a dual-bootable image of WinPE x86 + x64
The official MS bcdedit FAQ