How to Rebuild the EFI Boot Partition, BCD and Boot Files

The EFI boot partition is a FAT32 partition that stores the boot files and the boot configuration data (BCD) to load Windows. Sometimes, the boot partition or the BCD may get corrupted, and the boot files remain unserviceable by the Windows Setup process. In that case, rebuilding the EFI partition and recreating the BCD & boot files should resolve the issue.

Although rebuilding the EFI is easy, I advise creating an image backup (using Macrium Reflect or similar utilities) of your complete system, especially if you’re new to Windows RE and DiskPart. This is because it can be risky if you inadvertently type an incorrect drive-letter or volume # in DiskPart.

And, of course, the drive letters and Volume numbers used in this article are valid only for this computer. The drive-letters and volume # in your computer will vary depending on your disk layout.

Also, this article applies only for UEFI-based computers. If you’re using legacy boot/MBR disk, this article doesn’t apply. See How to Find if a Disk Uses MBR or GPT

The below demonstration was done from a Windows 11 computer.

Rebuild the EFI Partition, BCD, and Boot Files

1] Boot into Windows RE

Boot into the native Windows Recovery Environment (WinRE). To do so, click Start, click on the Power button, press and hold the Shift key down, and click Restart.

This starts the Windows Recovery Environment.

Alternatively, on the Windows sign-in screen, press and hold the Shift key while you select Power → Restart.

RELATED: See Different ways to access the Windows Recovery Environment (WinRE)

(If the native WinRE can’t be enabled on your computer, you can create a bootable USB setup disk and boot it into WinRE.)

In Windows RE, click Troubleshoot → Advanced Options → Command Prompt.

windows RE advanced options/command prompt

2] Find the OS Partition’s Drive-letter

In Command Prompt, type bcdedit and press Enter.

Note down the drive letter of your Windows installation.

Hint: Look at the “device“, “description“, “osdevice“, and “path” (winload.efi) values to determine the Windows partition.

bcdedut find windows drive letter osdevice

In the above example, the Windows drive letter (when seen from native WinRE) is E:

3] Assign a drive-letter for the EFI partition

Type DiskPart and press Enter.

In the DiskPart environment, type list volume  (or “lis vol” for short.)

Note down the volume number of the EFI partition. If the EFI partition doesn’t have a volume label, you can identify the partition by its file system and size.

(Hint: The EFI partition uses the FAT32 file system. Typically, the EFI partition’s size will be in the range of 100 MB to 500 MB, although 500 MB is certainly not a mandatory upper limit. On some systems, the EFI partition may show up as “RAW” instead of “FAT32” and the boot files may be inaccessible. It again indicates a corrupt partition.)

diskpart - rebuild efi boot and bcd

Once you have identified the Volume # of the EFI partition, which in this case, is “Volume 3”, type the following command:

select volume 3

And then type:

assign letter=y

You should see the output: “DiskPart successfully assigned the drive letter or mount point.”

You’ve now assigned the EFI partition a drive letter (Y:)

Now, run the following command to fix the EFI partition’s identifier:

(Note: The following command-line doesn’t appear in the above screenshot. But it’s recommended to run it.)

set id=c12a7328-f81f-11d2-ba4b-00a0c93ec93b

The above step ensures that the EFI partition’s identifier is correctly set. The identifier c12a7328-f81f-11d2-ba4b-00a0c93ec93b represents the EFI system partition. Reference: set id | Microsoft Learn.

Type exit to quit the DiskPart environment.

Tip: To cross-verify if Y: or Volume 3 in this example is the EFI boot partition, run the DIR Y: command. You should see a directory named EFI.efi partition DIR command

4] Backup the BCD and Boot Files (Optional step)

Next, let’s backup the boot files and the BCD database to a different location on the hard drive — to E:\, which is your Windows partition in this example. This is an optional step anyway.

Note: Skip this step if your EFI partition’s file system shows up as RAW instead of FAT32. Because the command will fail with error code 1005 (0x000003ED) when run on a RAW partition.

EFI partition shows as RAW

In the Command Prompt window, type:

robocopy Y:\EFI  E:\EFI.BAK /MIR /R:1 /W:1

robocopy command efi backup

The boot files and the BCD are now backed to the E:\ drive.

robocopy summary efi backup

The summary shows that every file and folder has been copied (mirrored) to the E:\EFI.BAK directory.

NOTE: If the above Robocopy command gets stuck in a loop, press Ctrl + C to stop its execution. Proceed to the next step in this article.

Tip: In addition to the above, you can individually backup the boot configuration database (BCD) file to another location if you want. To do so, run this command:

bcdedit /export E:\BCD.BAK

5] Format the EFI boot partition

Formatting the EFI boot partition is usually not required. However, if Windows Setup or the Windows Update process cannot service the boot files and causes the error 0x800F0922, 0x80070002 (see this example), etc., you may need to reformat the EFI partition and regenerate the BCD and boot files.

To format the EFI partition (Volume 3 or Y: in this example), run:

format y: /fs:FAT32 /q

Type the current volume label, as seen in the DiskPart output earlier. If the current volume label is empty, simply press Enter.

format EFI boot partition

Click Y when prompted to proceed with the format.

Type in the new volume label — e.g., EFI, ESP, etc.

6] Rebuild the BCD and Boot Files

Type the following command to regenerate the BCD and the boot files. The boot files will be sourced from the Windows directory.

bcdboot E:\Windows /s Y: /f UEFI

regenerate the boot files and BCD

The output should show the message “Boot files successfully created.”.

(Instead, if you see the error “Failure when attempting to copy boot files,” you’re probably typing the wrong drive-letter. Please recheck your Windows drive-letter by running bcdedit.)

Note for dual-boot configurations

If you have a dual-boot or multi-boot Windows configuration (e.g., a parallel installation on another drive or partition), read below:

For dual-boot or multi-boot Windows computer, additionally, run the following command to add those installations to the Boot Configuration Database.

bootrec /rebuildbcd

The above command scans all disks for Windows installations. You should see the “Successful Windows installations: #” message showing the list of Windows installations on the computer.

If additional installations are detected, press “A” to add all the detected Windows installations into BCD.

bootrec rebuildbcd scan

Here’s a sample output:

Scanning all disks for Windows installations.

Please wait, since this may take a while...

Successfully scanned Windows installations.
Total identified Windows installations: 1
[1]  F:\Windows
Add installation to boot list? Yes(Y)/No(N)/All(A):A
The operation completed successfully.
Note: If you ran the bcdboot command earlier, bootrec lists only the additional Windows installations, if any is present. If the BCD already includes a Windows installation entry, bootrec does NOT create a duplicate entry. And, if no additional instances are present, bootrec output shows “Total identified Windows installations: 0”.

That’s it. The EFI partition, the boot files, and the BCD have now been rebuilt.

One small request: If you liked this post, please share this?

One "tiny" share from you would seriously help a lot with the growth of this blog. Some great suggestions:
  • Pin it!
  • Share it to your favorite blog + Facebook, Reddit
  • Tweet it!
So thank you so much for your support. It won't take more than 10 seconds of your time. The share buttons are right below. :)

Ramesh Srinivasan is passionate about Microsoft technologies and he has been a consecutive ten-time recipient of the Microsoft Most Valuable Professional award in the Windows Shell/Desktop Experience category, from 2003 to 2012. He loves to troubleshoot and write about Windows. Ramesh founded in 2005.

Leave a Reply