This article will show you how to manually restore an accidentally deleted Windows EFI boot partition on a UEFI computer. This easy way to manually re-create bootable EFI and MSR Windows partitions will allow you to boot the operating system after accidentally formatting or deleting an EFI partition. This guide is relevant to all Windows versions (including Windows 10 and 11, and Windows Server 2022/2019/2016).
Suppose that the EFI boot partition on your UEFI (non-BIOS) computer was accidentally deleted or formatted (for example, when you tried to remove an OEM recovery partition). As a result, your Windows 11/10/8.1/7 doesn’t boot correctly and cycle prompting you to select the boot device (Reboot and select proper boot device or insert boot media in selected boot device and press a key
). Next, we will show how to restore Windows boot after deleting the EFI System disk partition (with a Boot Manager and BCD configuration) without reinstalling the OS.
UEFI/GPT-based Hard Disk Partitions in Windows
Consider how the default partition table of a boot hard drive with GUID partition table (GPT) on the UEFI computer should look like. You should have at least the following partitions:
- EFI System Partition (ESP – Extensible Firmware Interface) — 100 MB (partition type — EFI);
- Microsoft Reserved partition — 16 MB (partition type — MSR);
- Primary Windows partition (the partition containing Windows).
This is the minimum configuration. These partitions are created by Windows Installer during a clean install of the OS to an unformatted drive.
Computer manufacturers or users can create additional partitions containing, for example, Windows Recovery Environment (Windows RE) in the winre.wim file, a partition with the system image backup provided by the OEM (allows to roll back to the original state of the computer), user partitions, etc.
The EFI partition with the FAT32 file system is a mandatory partition on GPT disks on UEFI computers and has the GUIDc12a7328-f81f-11d2-ba4b-00a0c93ec93b
. The default size of the EFI partition is 100 MB (on advanced format disks with 4KB sectors the size of the EFI partition is 260MB).
The MSR partition (Microsoft System Reserved) on the GPT disk is used to simplify partition management and is used for service operations (for example, when converting a disk from basic to dynamic). This is a partition with the GUID label e3c9e316-0b5c-4db8-817d-f92df00215ae
with no drive letter assigned. This partition can’t store user data. In Windows 10 and 11, the size of the MSR partition is only 16 MB (in Windows 8.1 the MSR size is 128 MB), and the file system is NTFS. The MSR partition must be between the EFI System partition (ESP) and the primary Windows operating system partition.
The main partition with the NTFS file system contains the installed Windows, programs, and user data. There may also be additional data partitions on the disk.
Missing EFI Partition in Windows
The EFI partition (similar to the System Reserved partition on drives with the MBR partition table) stores the boot configuration store (BCD) and a number of files needed to boot Windows. When the computer boots, the UEFI environment loads the bootloader file (EFI\Microsoft\Boot\bootmgfw.efi) from the EFI System (ESP) partition and transfers control to it. The bootmgfw.efi executable launches the Windows Boot Manager, which loads configuration data from the BCD. Once the BCD is loaded, Windows starts booting via winload.efi.
When a UEFI computer boots, it looks for the EFI system partition on all attached drives. If the EFI partition is deleted or corrupted, you won’t be able to boot Windows from that drive. A UEFI error will appear could not locate \efi\boot\bootx64.efi – not found
or an empty UEFI Shell prompting you to select a boot device.
Also, you won’t be able to boot Windows if the EFI partition is formatted with the NTFS file system. Even then performing a clean Windows installation, you will receive an error:
Windows detected that the EFI system partition was formatted as NTFS. Format the EFI system partition as FAT32, and restart the installation.
How to Create EFI System and MSR Partitions on GPT Drive?
Because Windows doesn’t correctly, we’ll need a Windows 10/11 installation drive (see how to create a UEFI Bootable USB drive with Windows install files) or any other boot/rescue media. Boot from the installation media and press the Shift+F10 key combination on the first installation screen. A command prompt window should open.
Run the disk and partition management tool:
Diskpart
List the hard disks connected to the computer:
list disk
In our example, there is only one disk 0 connected. The asterisk (*) in the GPT column indicates that a GUID partition table has been created on the disk.
*
in the GPT column, then the disk partition table is MBR. You need to make sure that you previously booted your computer in the native UEFI mode (otherwise, following this instruction is pointless). If you are sure that the partition table type has changed, it may be worth converting the drive from MBR to GPT.Select this disk:
Select disk 0
Display the list of partitions on the disk:
List partition
In my example, only three partitions are left on the drive:
- MSR partition — 16 MB
- Windows system partition — 30 GB
- Recovery partition – 541 MB
As you can see, the EFI partition (may be called System) is missing (has been deleted).
Our task is to remove the remaining MSR partition so that we have at least 116 MB of unallocated space on the disk (for MSR and EFI partitions). You can remove this partition using the graphical Gparted tool or directly from the command prompt (that’s exactly what we’ll do).
Select the partition to remove:
Select partition 1
And delete it:
Delete partition override
Make sure that there is only 30 GB primary Windows partition and the recovery partition left (in our case):
List partition
You can now manually create the EFI and MSR partitions to place the Windows bootloader files. To do it, run these commands in the diskpart context one by one.
Select the disk:
select disk 0
Create a 100 MB EFI partition:
create partition efi size=100
Make sure that the 100 MB partition is selected in diskpart (an asterisk before Partition 1). Format your EFI partition with FAT32 file system, and assign a drive letter to it:
list partition
select partition 1
format quick fs=fat32 label="System"
assign letter=G
Now you need to create a 16MB MSR partition (for Windows 10 or 11).
create partition msr size=16
list partition
list vol
In my case, the drive letter C: is already assigned to the main Windows partition. If it’s not, assign the drive letter to it as follows:
select vol 1
assign letter=C
exit
Close the diskpart:
exit
An error may appear when creating an EFI or MSR partition using diskpart:
No usable free extent could be found. It may be that there is insufficient free space to create a partition at the specified size and offset. Specify different size and offset values or don't specify either to create the maximum sized partition. It may be that the disk is partitioned using the MBR disk partitioning format and the disk contains either 4 primary partitions, (no more partitions may be created), or 3 primary partitions and one extended partition, (only logical drives may be created).
This means that there is not enough unallocated (free) space on the disk for the new partition. In this case, you need to reduce the size of the main Windows partition (in our example, this is volume 1) by 128 MB:
select volume 1
shrink desired=128 minimum=128
Then create the EFI and MSR partitions as described above.
Repair the EFI bootloader and Windows BCD on a GPT Drive
After you have created a minimal disk partition structure for the GPT drive on the UEFI computer, you can proceed to copy the EFI boot files to the new partition and create a bootloader configuration file (BCD).
Now use the bcdboot.exe tool to copy the UEFI boot environment files from the Windows system directory to the EFI boot partition and recreate the BCD bootloader configuration. Run the command:
bcdboot c:\windows /s G: /f UEFI
Boot files successfully created.
As a result, a predefined directory structure will be created on the EFI partition. The following files must be present on the EFI system volume:
- \EFI\Microsoft\Boot\bootmgfw.efi
- \EFI\Microsoft\Boot\bootmgr.efi
- \EFI\Microsoft\Boot\memtest.efi
- \EFI\Microsoft\Boot\BCD
- \EFI\Microsoft\Boot\Fonts\wgl4_boot.ttf
- \EFI\Boot\bootx64.efi
List the current Windows Boot Manager bootloader configuration. An entry should appear in the {bootmgr} section pointing to the partition containing the UEFI boot control file (\EFI\MICROSOFT\BOOT\bootmgfw.efi
). In this example, it is partition=G
, or partition=\Device\HarddiskVolume2
(if you haven’t assigned a drive letter for the EFI partition).
The UEFI bootloader must then pass the control to the Windows Boot Loader file \Windows\system32\winload.efi
on partition=C
:
Reboot your computer (use the wpeutil reboot
command in order to reboot from the WinPE environment) and remove the bootable USB flash drive.
Copy the EFI environment boot files from the directory of your drive where your Windows is installed:
mkdir G:\EFI\Microsoft\Boot
xcopy /s C:\Windows\Boot\EFI\*.* G:\EFI\Microsoft\Boot
Rebuild the Boot Configuration Data (BCD) entry in Window Boot Manager:
g:
cd EFI\Microsoft\Boot
bcdedit /createstore BCD
bcdedit /store BCD /create {bootmgr} /d “Windows Boot Manager”
bcdedit /store BCD /create /d “My Windows 10” /application osloader
The command returns the GUID of the created BCD entry. Use this GUID instead of {your_guid} in the following command:
bcdedit /store BCD /set {bootmgr} default {your_guid}
bcdedit /store BCD /set {bootmgr} path \EFI\Microsoft\Boot\bootmgfw.efi
bcdedit /store BCD /set {bootmgr} displayorder {default}
The following bcdedit commands are run in the {default} context:
bcdedit /store BCD /set {default} device partition=c:
bcdedit /store BCD /set {default} osdevice partition=c:
bcdedit /store BCD /set {default} path \Windows\System32\winload.efi
bcdedit /store BCD /set {default} systemroot \Windows
exit
If Windows didn’t boot correctly the first time, try the following:
- Power off your device;
- Unplug (physically) your hard drive;
- Turn your computer on, wait till the boot error window appears (An Operating System not found), and turn it off again;
- Plug your drive back.
If this doesn’t help, boot from the installation USB flash drive and run the command:
bootrec /rebuildbcd
Restart your computer
Then in our case (tested on a VMWare virtual machine with UEFI firmware), we had to add a new item to the boot menu by selecting the EFI\Microsoft\Boot\bootmgrfw.efi file on the EFI partition.
In some UEFI menus, by analogy, you need to change the priority of boot partitions.
After all these actions, your Windows should boot correctly.
In some cases, after recreating the EFI and MSR partitions and restoring the BCD bootloader, Windows may stop shutting down gracefully. If you experience this problem, you can fix it by disabling the Fast Startup feature in Windows:
- Open the Power Options in the Control Panel
powercfg.cpl
; - Select Choose what the power button does;
- Click the Change settings that are currently unavailable button and disable the “Turn on fast startup” option in the “Shutdown settings” section.