Repairing EFI/GPT Bootloader using the DISKPART and BCDEdit command

Resources


This guide helps repair bootloader issues, for example getting a blue screen of death with the following error:

The boot configuration data for your PC is missing or contains errors.

Use diskpart to make System partition available.

(This will allow us to use bcdedit later in this guide to repair the bootloader.)

Boot from the Windows installation media

When at the Install Windows screen hit Shift+F10 to bring up a command prompt.

Type diskpart, then type list disk:

DISKPART> list disk

  Disk ####  Status         Size     Free     Dyn  Gpt
  --------  -------------  -------  -------  ---  ---
  Disk 0    Online          465 GB  1024 KB        *
  Disk 1    Online           14 GB      0 B
  Disk 2    Online         7695 MB      0 B

.

Select boot disk

You need to "Select" a disk before continuing. If only one disk shows, type, select disk 0. If there is more than one disk, they will need to verify based on disk size. If it is not disk 0 they would replace 0 with the number of the drive. (In my sample above, it is hopefully clear that '0' is the boot drive and the other two are not.)

DISKPART> select disk 0

Disk 0 is now the selected disk.

Verify Partitions

Type, list par, to verify that there are 4 partitions, Recovery, System, Reserved, Primary.

DISKPART> list par

  Partition ####  Type              Size     Offset
  -------------  ----------------  -------  -------
  Partition 1    Recovery           450 MB  1024 KB
  Partition 2    System              99 MB   451 MB
  Partition 3    Reserved            16 MB   550 MB
  Partition 4    Primary            464 GB   566 MB
  Partition 5    Recovery           847 MB   464 GB

.

Select volume to use

Type, list vol, the volume number they want to use in the next step will have a FAT32 file system and should be 99MB with System under info.

DISKPART> list vol

  Volume ####  Ltr  Label        Fs     Type        Size     Status     Info
  ----------  ---  -----------  -----  ----------  -------  ---------  --------
  Volume 0     C                NTFS   Partition    464 GB  Healthy    Boot
  Volume 1         Recovery     NTFS   Partition    450 MB  Healthy    Hidden
  Volume 2                      FAT32  Partition     99 MB  Healthy    System
  Volume 3                      NTFS   Partition    847 MB  Healthy    Hidden
  Volume 4     F                FAT32  Removable     14 GB  Healthy
  Volume 5     E   IRON MAN     FAT32  Removable   7695 MB  Healthy

In this example, this is Volume 2.

Type, select vol 2, (number identified from previous step), i.e. select vol 2

DISKPART> select vol 2

Volume 2 is the selected volume.

Type, assign letter=z and should see "Diskpart successfully assigned the drive letter".

DISKPART> assign letter=z

DiskPart successfully assigned the drive letter or mount point.

Type exit (Z: drive is now the System partition)

Set up EFI boot partition using bcdedit (Boot Configuration Data editor)

  1. Type mkdir Z:\EFI\Microsoft\Boot

  2. Type xcopy /s C:\Windows\Boot\EFI*.* Z:\EFI\Microsoft\Boot

  3. Type z:

  4. Type cd EFI\Microsoft\Boot

  5. Type the following commands

    1. bcdedit /createstore BCD

    2. bcdedit /store BCD /create {bootmgr} /d "Windows Boot Manager"

    3. bcdedit /store BCD /create /d "My Windows 10" /application osloader (they can change My Windows 10 to anything they want)

      The last command will return a GUID, for example, {D91FE7C2-605F-4A2B-B035-80A7C30979BF}, they will need to use this guid in the next step

  6. Type the following commands

    1. bcdedit /store BCD /set {bootmgr} default {your_guid} (your_guid will be the guid mentioned in step 9)

    2. bcdedit /store BCD /set {bootmgr} path \EFI\Microsoft\Boot\bootmgfw.efi

    3. bcdedit /store BCD /set {bootmgr} displayorder {default}

    4. bcdedit /store BCD /set {default} device partition=c:

    5. bcdedit /store BCD /set {default} osdevice partition=c:

    6. bcdedit /store BCD /set {default} path \Windows\System32\winload.efi

    7. bcdedit /store BCD /set {default} systemroot \Windows

    8. exit

  7. Reboot the machine.


Last Update: 24 November, 2020