Repair the UEFI-GPT bootloader in Windows 10 or 11

Here's how to repair the Windows bootloader, on a modern computer that uses UEFI instead of classic BIOS, and the disk has a GPT partition system instead of MBR.

boat

Corruption of the Windows launcher can occur after installing a second operating system (in Dual Boot configurations), or after file system corruption, incorrect actions during Windows recovery, removal of some data from hidden partitions, (viruses, ransomware, etc.) and for some other reasons.

We lost it because when cloning a hdd disk to a new ssd it didn't do us the favor of keeping all the data!

If you find yourself in a similar position, see step-by-step what to do to repair a damaged or deleted bootloader in Windows 11/10/8.1 and Windows Server 2022/2019/2016/2012R2, on computers running in UEFI mode.

The following steps can be used to both repair the Windows bootloader binaries and configure the bootloader \EFI\Microsoft\Boot\BCD, in cases where Windows does not boot due to deletion of the BCD boot configuration file or his destruction.

Windows startup error due to boot configuration data

A UEFI computer with Windows installed in native mode (ie not through emulation) will not be able to boot if the Windows EFI bootloader is corrupted. When trying to boot from a disk with a damaged or missing EFI bootloader (EFI = Extensible Firmware Interface), the following BSOD (Blue Screen of Death) error appears:

The boot data for your PC is missing or contains errors.
File :\EFI\Microsoft\Boot\BCD
Error code: 0xc000000f

the:

Error code: 0xc000014c

bsod 0xc0000014c

This error indicates that the Windows boot configuration (Boot Configuration Data = BCD) is corrupt or even non-existent. If you try to repair the bootloader on a UEFI computer using a bcdedit tool, you will get an error:

The boot configuration data store could not be found.
The requested system device cannot be found.

If Windows 10/11 is installed on computer with UEFI function and to disk with GPT partition system, then the Windows EFI bootloader (Windows Boot Manager) stores the boot manager (boot management) and BCD configuration (BCD configuration) in a separate hidden EFI volume (size 100 MB in FAT32 file system).

The bcdedit tool does not see this EFI partition and cannot manage bootloader configuration on it.

Note: The EFI partition on a disk is part of the version of Windows and also part of other operating systems (OS), such as Linux and macOS. EFI stands for Extensible Firmware Interface.
As the name suggests, EFI connects the operating system to the firmware) of the hardware components in a computer. When a computer boots, the UEFI firmware loads files stored in the EFI to start the installed operating systems and various utilities.

If when you start your computer you only see a black screen with the message “An operating system wasn't found”, it is possible that the Windows bootloader has been completely removed. Whatever the case may be, follow the instructions below.

Automatic repair of Windows Bootloader with WinRE in UEFI and GPT

The procedure for automatically repairing the EFI bootloader from the Windows Recovery Environment (WinRE = Windows Recovery Environment) is usually useless in such cases. But it is worth trying:

  • Boot your device from the recovery disc or Windows 10/11 installation disc.
  • Click Restore System on the installation screen.
  • Then select Troubleshoot -> Boot Repair and select the OS whose bootloader you want to repair.
    Recovery,Windows,EFI,BCD,bcdboot,bootrec,diskpart,bootloader

We don't want to disappoint you, but probably the result is negative, and you get the message: Automatic Repair couldn't repair your PC

Using BCDBoot to Manually Repair EFI Bootloader on Windows in UEFI and GPT

Let's start the process of manually repairing the Windows EFI bootloader on a UEFI computer.

To repair the bootloader configuration (BCD), you must boot from the original Windows installation media (you can also use a recovery disc or a special UEFI-bootable USB flash drive). After booting into the recovery environment, you need to open a Command Prompt console. For this choose in order: System Restore -> Troubleshoot-> Command Prompt (or in Greek Command Prompt).

You can run the command line even if you only have one Windows media. To do this, it is enough to press the key combination Shift + F10 (or Shift + Fn + F10, on some models of laptops) on the first Windows installation screen (when selecting the language and keyboard layout).

[scm] actwin, 0,0,0,0; desktop 12/4/2013, 11:23:23 am

In the command prompt that will open, run the disk management tool:
diskpart

And display the list of drives on the computer:
list disk

Caution:____________________________________________________
At this stage, it is very important to determine the type of partition table on the disk on which your Windows is installed: MBR ή GPT. The thing is that the EFI bootloader is only used on disks with a GPT partition system.

If there is an asterisk (*) in the Gpt column, then your disk uses the GPT partition table. If not, use the MBR.

diskpart get disk partition table gpt or mbr

 

 

 

If your disk uses a GPT partition table, follow these steps to repair your Windows EFI boot loader.

If you have an MBR partition board on your disk, this wizard will not work for your computer!. You probably have a computer with BIOS or Legacy/Compatibility Support Mode (CSM) in the UEFI settings.

On MBR disks, the Windows boot loader is stored in a separate System Reserved partition, and not in the EFI partition (under no circumstances, do not convert the MBR partition table to GPT until you fix the Windows boot program !!).

In this case, use another guide to restore the BCD bootloader on a BIOS computer with an MBR (Master Boot Record) disk.


We continue. Select the drive on which your Windows is installed (if there is only one hard drive in the system, its index should be 0):
sel disk 0

List the partitions and volumes on this disk with the command
list partition

See the volumes with:
list volume

window efi partition table structure

In this example, you can see that the EFI boot partition has the index partition 2 (but you also see it as Volume 5 -labeled Hidden). The easiest way to figure out the EFI partition is the FAT5 file system and its size of 32 MB (this is the standard minimum size of the EFI partition for Windows computers. In rare cases, the partition size may vary). The most commonly used label for this is System EFI or ESP/EFI System Partition.

In our example, the main partition in which Windows is installed has a volume index of 2, is formatted in the NTFS file system, and is assigned the drive letter C :.

Run the command: dir C:\ to make sure that this drive contains the Windows, Program Files, Users, and other known Windows directories.

identify windows system partition in winpe

If these directories are missing, then your Windows drive has a different drive letter. Check the contents of other drives with different drive letters assigned to find it.

Record the drive letter assigned to the Windows partition. You will use it as one of the arguments in the bcdboot command a little later.

The partition table must also contain a 16 MB MSR (Microsoft System Reserved) partition in Windows 10/11 (or 128 MB in Windows 8.1).

default efi partitions

If you don't have a separate EFI or MSR partition, you can recreate them manually. If they exist, and their contents are simply damaged or empty, continue with our instructions.

Assign drive letter K: to the hidden EFI volume (K is random, just put a letter that is not yet assigned):
select volume 5
assign letter K:

You should see a message that the drive letter has been successfully assigned to the EFI partition:
DiskPart is successfully assigned the drive letter or mount point.

Close diskpart:
exit

Go to the bootloader directory in the hidden volume:
cd /d K:\efi\microsoft\boot\

In this case, K: is the drive letter assigned to the EFI partition immediately above. If the \EFI\Microsoft\Boot\ directory is missing (error The system cannot find the path specified), try the following commands:

cd /d K:\Boot\
ή
cd /d K:\ESD\Windows\EFI\Microsoft\Boot\
--------------------------------
At this point, many drivers recommend executing the following commands, which should replace the boot record of the partition, find the installed Windows, and add them to the BCD:

bootrec /fixboot
bootrec /scanos
bootrec /rebuildbcd

or even:
bootrec /FixMbr
(priming an MBR record for a GPT disk seems a strange action)

You can use all of these commands only for MBR-based disks. If your computer starts in UEFI mode, then it definitely uses the GPT partition board (as in our case). Therefore, when running bootrec commands, you will see the error: “access is denied”
--------------------------------

You must use the BCDBoot.exe tool to restore the bootloader files and fix the boot entries on the EFI partition by copying them from the system directory to the Windows partition.

The BCD bootloader configuration is recreated using the file: %WINDIR%\System32\Config\BCD-Template.

Use the attrib command to remove hidden, read-only system attributes from the BCD file:
attrib BCD -s -h -r

Delete the current BCD configuration file by renaming it (this will keep the old boot configuration as a copy ): ren BCD BCD.bak

Using the bcdboot tool, you need to copy the critical UEFI boot environment files from the system directory to the EFI boot partition and rebuild the BCD bootloader configuration file:
bcdboot C:\Windows /l en-us /s k: /f ALL

  • C: \ Windows - the path to the root directory of the Windows system on the disk (this is your disk on which your Windows is installed, we identified it earlier using the diskpart command).
  • / f ALL – means you need to copy the Windows Boot Environment files, including those for UEFI and BIOS computers (theoretically they can boot on both UEFI and BIOS computers). To copy only the EFI bootloader, use the command / f UEFI .
  • /l en-us —specifies the system locale used when initializing the BCD storage. By default, en-us – English (US) is used.
  • / s K: - copy the bootloader EFI files to the specified partition.
  • /c – this is a new option of BCDBoot in Windows 10 that allows you to overwrite existing boot entries (including debug settings). Use this option to ignore the old boot settings and create a clean BCD configuration.
  • /v - used to activate BCDBoot verbose output.

Suggestion. If you are using a local version of Windows 10/11, the command will be different. For example, in the Windows version of Greece use the following command:
bcdboot c:\Windows /l el-GR /s K: /f ALL

For the United Kingdom:
bcdboot c: \ Windows / l en-GB / s K: / f ALL

Windows 10 Dutch:
bcdboot c: \ Windows / l nl-NL / s K: / f ALL

Windows 10 German:
bcdboot c: \ Windows / l de-DE / s K: / f ALL

A complete list of language/region tags for Windows is available here:
https://docs.microsoft.com/en-us/windows-hardware/manufacture/desktop/available-language-packs-for-windows?view=windows-11

Now if you run the bcdedit command you will see the following:

You should see an entry in the Windows Boot Manager section containing the full path to the UEFI boot file (\EFI\MICROSOFT\BOOT\BOOTMGFW.EFI).
In this example, it is on volume 5 (partition=\Device\HarddiskVolume5).

bcdedit windows boot manager bootmgfw efi

Windows Boot Manager -------------------- identifier {bootmgr} device partition = \ Device \ HarddiskVolume5 path \ EFI \ Microsoft \ Boot \ bootmgfw.efi description Windows Boot Manager locale en-US inherit {globalsettings} bootshutdowndisabled Yes default {CURRENT} resumeobject {xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx} displayorder {default} 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 {xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx en recoveryenabled Yes isolatedcontext Yes allowedinmemorysettings 0x15000075 osdevice partition = C: systemroot \ Windows resumeobject {xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx x

The Windows Boot Manager section must contain the path to the EFI partition (=\Device\HarddiskVolume5) and the path to the boot manager file (bootmgfw.efi).

The Windows Boot Loader section contains the Windows partition information and the path to the Windows EFI bootloader (\ Windows \ system32 \ winload.efi). When you turn it on, your computer will pass the test to the Windows EFI bootloader, which will start the Windows starter.

Possible errors:

  • BFSVC Error: Could not open the BCD template store. status - [c000000f]. Check that the command you entered is correct and that you have a local version of Windows installed. In this case, you must specify the correct locale code.
    The bcdboot tool copies the BCD template files from the \ Windows \ System32 \ Config directory. If the BCD template files in this folder are corrupted or deleted, try checking the integrity of the offline system files using the sfc.exe tool (you need a Windows installation disc as the source, say it is on drive D :): sfc /scanow /OFFBOOTDIR=C:\ /OFFWINDIR=D:\WINDOWS
  • BFSVC Error: Error copying boot files from Last Error = 0x570 - Try to control the unit using the C commandHKDSK K: /F
  • BFSVC Error: Failed to set element application device. Status = [c000000bb] – Check EFI and Windows 10 partitions using chkdsk.exe. Make sure that the “hidden” and “filesystem” designations from the BCD file have been removed:
    bcdboot bfsvc error
    attrib -s -h \EFI\Microsoft\Boot\BCD
    del \EFI\Microsoft\Boot\BCD
  • Failure when initializing library system volume - Make sure you are using the correct FAT32 partition with EFI (you may have several similar partitions).
  • Failure when attempting to copy boot files – Check the Windows drive letter in the bcdboot command. The following screenshot shows that the error occurred when trying to copy the boot files from the C: drive. In this case, the Windows drive is probably assigned a different letter, such as D:. You can find your Windows drive and the assigned drive letter using the diskpart and dir commands (described above).
    bcdboot failure when attempting to copy boot files

 

 

Now you need to restart your computer and unmount the bootable media. If you did everything right, o Windows Boot Manager (Windows Boot Manager) should appear in the list of bootable devices where you can select the desired operating system to boot. EFI bootloader and BCD configuration settings will be successfully restored!

In some cases, after repairing the BCD boot program, an error occurs when you start Windows BAD SYSTEM CONFIG INFO. To fix the error:
Make sure you have not made any recent changes to the UEFI settings. Undo all changes.

Start your computer from the installation / boot flash drive and change the bootloader configuration with the commands:

  • bcdedit /deletevalue {default} numproc
  • bcdedit /deletevalue {default} truncatememory

Also, it might not give you the option to choose the boot operating system of your choice (dual boot), not even the recovery Windows partition. In this case you should:

  • In a command prompt with administrator rights enter diskpart
  • Give the partition that contains the Windows recovetry or other operating system a letter with the assign command
    assign letter R: (R is a random letter)
  • And use the free program EasyBCD to add the alternative starting points

We will describe this case in more detail in another article.

Good Luck!

iGuRu.gr The Best Technology Site in Greecefgns

every publication, directly to your inbox

Join the 2.086 registrants.
Recovery,Windows,EFI,BCD,bcdboot,bootrec,diskpart,bootloader

Written by Dimitris

Dimitris hates on Mondays .....

Leave a reply

Your email address is not published. Required fields are mentioned with *

Your message will not be published if:
1. Contains insulting, defamatory, racist, offensive or inappropriate comments.
2. Causes harm to minors.
3. It interferes with the privacy and individual and social rights of other users.
4. Advertises products or services or websites.
5. Contains personal information (address, phone, etc.).