Skip to main content
WindowsWindows 10

How to Restore Deleted EFI System Partition in Windows 10

By February 10, 2021No Comments

In this post we’ll show you how to manually restore an accidentally deleted Windows EFI boot partition on a UEFI computer. We’ll look at an easy way to manually recreate system EFI and MSR partitions in Windows, which will allow you to boot the OS after accidentally formatting or deleting an EFI partition. The instructions in this post are relevant for all versions of Windows, from Win 7 to Windows 10.

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 Windows 10/8.1/ 7 doesn’t boot correctly, cyclically 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).
Let’s figure out if it is possible to start Windows properly after deleting the EFI partition (with a Boot Manager and BCD configuration) without reinstalling the OS.
Warning. This guide implements working with disk partitions and is not recommended for beginners. If you interpret the commands wrongly, you can accidentally delete all data on your hard disk. It is also strongly recommended to backup important data on a separate media.

GPT Hard Disk Partition Structure in Windows

Consider how the default partition table of a bootable 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 — 128 MB (partition type — MSR);
  • Primary Windows partition (the partition containing Windows).
Default efi partitoions

This is the minimum configuration. These partitions are created by the Windows Installer when you perform a clean OS install on an unformatted drive. Computer manufacturers or users can create their own 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 GUID c12a7328-f81f-11d2-ba4b-00a0c93ec93b. The default size of the EFI partition is 100MB (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 backup partition with the GUID label e3c9e316-0b5c-4db8-817d-f92df00215ae. The MSR partition doesn’t receive a drive letter. This partition can’t store user data. In Windows 10, the size of the MSR partition is only 16 MB (in Windows 8.1 the size of the MSR partition is 128 MB), the file system is NTFS. The MSR partition must be  located between the EFI partitions (ESP) and the primary Windows operating system partition.

The main partition contains the installed Windows, programs and user data. Additional data partitions may be present.
Tip. To install Windows on computers with UEFI you will need an original DVD or a specially prepared bootable USB flash drive with Windows 10 for UEFI computers.

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 required to boot Windows. When the computer boots, the UEFI environment loads the bootloader (EFI\Microsoft\Boot\bootmgfw.efi) from the EFI (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.

If the EFI partition is deleted or damaged, you won’t be able to boot Windows from that drive. UEFI error “could not locate \efi\boot\bootx64.efi – not found” appears , or an empty UEFI Shell prompting you to specify a boot device.

Also, you will not 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 Manually Create EFI and MSR Partitions on GPT Drive?

Since the system doesn’t boot correctly, we’ll need Windows installation media with Windows 10 (Win 8 or 7) image or any other boot/rescue media. Boot from the installation media and on the first installation screen press the Shift+F10 key combination. The command prompt window opens.

Shift+F10 - command prompt

Run the disk and partition management tool:

Diskpart

List the hard disks connected to the computer (in our example, there is only one disk, disk 0. The asterisk (*) in the GPT column means that it uses the GUID partition table). If there is no * 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 instructions is pointless). If you are sure that the partition table type has changed, it may be worth converting drive from MBR to GPT.

list disk

Select this disk:

Select disk 0

Display the list of partitions on the disk:

List partition

In our example, only two partitions are left on the drive:

  • MSR partition — 128 MB;
  • Windows system partition — 9 GB.

As you can see, the EFI partition is missing (it has been deleted).

diskpart list partition

Tip. If only EFI files were damaged on the EFI partition and the partition itself was not deleted, you can skip the process of recreating partitions using diskpart. Although in most cases it is enough to repair the EFI bootloader in Windows. You can manually recreate the BCD on an MBR+BIOS computer using this post.

Our task is to remove the remaining MSR partition so that we have at least 228 MB of unallocated space on the drive (for MSR and EFI partitions). You can remove this partition using the graphical Gparted or directly from the command prompt (that’s exactly what we’ll do).
Important! Please, be extremely attentive here and do not accidentally delete Windows partition or partitions containing user data (if there are any).

Select the partition to remove:

Select partition 1

And delete it:

Delete partition override

Make sure that there is only 9GB Windows partition left (in our case):

List partition
delete msr partition

Now you can re-create EFI and MSR partitions manually. To do so, run these commands in diskpart context one by one.

Select the disk:

select disk 0

Create a 100MB EFI partition, format it with FAT32 file system and assign a drive letter to it:

create partition efi size=100

Make sure that the 100 MB partition (an asterisk in front of the Partition 1) is selected:

list partition select partition 1 format quick fs=fat32 label=”System” assign letter=G

Now you need to create an MSR partition with a size of 128 MB (in Windows 10, it is enough to create 16 MB MSR partition).

create partition msr size=128 list partition list vol

In our case, the drive letter C: is already assigned to main Windows partition. Otherwise, assign the drive letter to it as follows:

select vol 1 assign letter=C exit
recreate efi and msr partitions

Repair the EFI bootloader and Windows BCD

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).

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
copy efi files

Rebuild the Window BCD bootloader configuration:

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

You can replace the caption “My Windows 10” for any other.

The command returns the GUID of the created entry. In the next command put this GUID instead of {your_guid}.

create bcd store
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}
bcdedit bootmgr

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
bcdedit winload efi

Restart your computer… In our case it didn’t boot the first time. Try the following:

  1. Turn your PC off;
  2. Unplug (physically)your hard drive;
  3. Turn your PC on, wait till the boot error window appears (An Operating System not found) and turn it off again;
  4. Plug your drive back.

Then in our case (the test took place on the 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 boot priority of partitions.

efi boot option FI\Microsoft\Boot\bootmgrfw.efi

After all these actions, your Windows should boot correctly.

setup is starting services

Tip. If something doesn’t work, it is recommended to make sure that only EFI partition has the boot flag. You can do it using GParted LiveCD.

Leave a Reply