How to restore deleted EFI system partition in Windows? , Ranjan.info

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 recreate the bootable EFI and MSR Windows partitions will allow you to boot the operating system after accidentally formatting or deleting the EFI partition. This guide is relevant for all versions of Windows (including Windows 10 and 11 and Windows Server 2022/2019/2016).

Suppose the EFI boot partition on your UEFI (non-BIOS) computer was accidentally deleted or formatted (for example, when you tried to delete the OEM recovery partition). As a result, your Windows 11/10/8.1/7 does not boot correctly and the cycle prompts you to select a boot device (Reboot and select proper boot device or insert boot media in selected boot device and press a key, Next, we’ll show how to restore Windows boot after deleting the EFI system disk partition (with Boot Manager and BCD configuration) without reinstalling the OS.

Warning, This guide assumes working with disk partitions and is not intended for beginners. If you misinterpret the commands, you may accidentally delete all the data on your hard disk. Backing up important data to a separate media is also highly recommended.

UEFI/GPT-based hard disk partitioning in Windows

Consider what the default partition table of a boot hard drive with a GUID partition table (GPT) should look like on a UEFI computer. You must 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 (partition containing windows,

default efi partition

This is the minimum configuration. These partitions are created by Windows Installer during a clean install of the OS on an unformatted drive.

Computer manufacturers or users can create additional partitions, for example, in the winre.wim file Windows Recovery Environment (Windows RE), a partition with system image backups provided by the OEM (allowing to return to the original state of the computer is) ), user partition, etc.

EFI partition On UEFI computers with the FAT32 file system GPT is a mandatory partition on the disk and has a GUIDc12a7328-f81f-11d2-ba4b-00a0c93ec93b, The default size of the EFI partition is 100 MB (The EFI partition size is 260MB on Advanced Format disks with 4KB sectors).

msr partition GPT (Microsoft System Reserved) is used on disks 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 a GUID label e3c9e316-0b5c-4db8-817d-f92df00215aeAssigned without a drive letter. This partition cannot store user data. The size of the MSR partition is the same in Windows 10 and 11. 16 MB (The msr size is 128MB in Windows 8.1), and the filesystem is NTFS. The MSR partition must be between the EFI System Partition (ESP) and the primary Windows operating system partition.

main division Contains Windows, programs, and user data installed with the NTFS file system. 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 a drive with the MBR partition table) stores the Boot Configuration Store (BCD) and many of the 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. launches the bootmgfw.efi executable Windows boot Manager, which loads configuration data from the BCD. Once the BCD is loaded, Windows begins booting through winload.efi.

uefi windows boot manager: set bootmgfw.efi path

When a UEFI computer boots, it looks for an EFI system partition on all attached drives. If the EFI partition has been deleted or corrupted, you may not be able to boot Windows from that drive. a UEFI error will appear could not locate \efi\boot\bootx64.efi – not foundOr an empty UEFI shell prompting you to choose a boot device.

Also, if the EFI partition is formatted with the NTFS file system, you will not be able to boot Windows. Even when 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 boot correctly, we’ll need a Windows 10/11 installation drive (see How to Create a UEFI Bootable USB Drive with Windows Install Files) or another boot/rescue media. boot from installation media and press Shift+F10 Key combination on the first installation screen. A command prompt window should open.

Run Disk and Partition Management Tool:
Diskpart
List the hard drives connected to the computer:

list disk

In our example, there is only one disk 0 are linked. Tarak (,) in the GPT column indicates that a GUID partition table has been created on the disk.

diskpart check gpt partition table

if there is no *In the GPT column, the disk partition table is MBR. You need to make sure you booted your computer in native UEFI mode first (otherwise, following this Instructable is pointless). If you’re sure the partition table type has changed, it might be worth converting the drive from MBR to GPT.

Select this disc:
Select disk 0
Display a list of partitions on a disk:
List partition
In my example, there are only three partitions left on the drive:

  • msr partition – 16MB
  • Windows System Partition – 30GB
  • recovery partition – 541MB

As you can see, the EFI partition (can be called SYSTEM) is missing (deleted).

EFI system partition missing on Windows disk

tip, If only the EFI boot files on the EFI partition were damaged and the partition itself was not deleted, you can skip the step of recreating the partition using Diskpart. In most cases, it is sufficient to proceed to repair the EFI bootloader in Windows. If you are using an MBR disk on a computer with BIOS firmware, you can recreate the BCD as described in this article.

Our task is to delete the remaining MSR partition so that we have at least 116 MB of free space on the disk (for MSR and EFI partitions). You can delete this partition with the graphical Gparted tool or directly from the command prompt (this is what we will do).

important! Please, be extremely careful here and don’t accidentally delete the Windows partition or the partition containing user data (if any).

Select the partition to delete:
Select partition 1
and delete it:
Delete partition override
Make sure there is only a 30 GB primary Windows partition and a recovery partition left (in our case):
List partition
delete msr and efi partitions with diskpart

You can now manually create EFI and MSR partitions to hold the Windows bootloader files. To do this, run these commands one by one in the diskpart context.

Select disc:
select disk 0
Create a 100 MB EFI partition:
create partition efi size=100
Make sure the 100MB partition is selected in Diskpart (an asterisk before partition 1). Format your EFI partition with the FAT32 file system, and assign it a drive letter:
list partition
select partition 1
format quick fs=fat32 label="System"
assign letter=G

Now you need to create 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 isn’t, assign it a drive letter as follows:
select vol 1
assign letter=C
exit

diskpart: create FEI partition

Shut down diskpart:

exit

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

Diskpart: No usable free extension could be found

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) to 128 MB:

select volume 1
shrink desired=128 minimum=128

shrink partition with diskpart

Then create EFI and MSR partitions as described above.

Repair EFI Bootloader and Windows BCD on GPT Drive

After you have created a minimal disk partition structure for a GPT drive on a UEFI computer, you can proceed to copy the EFI boot files to the new partition and create a bootloader configuration file (BCD).

use now bcdboot.exe Tool to copy UEFI boot environment files from Windows system directory to EFI boot partition and rebuild BCD bootloader configuration. Run command:

bcdboot c:\windows /s G: /f UEFI

Boot files successfully created.

BCDBoot: Restore UEFI Bootloader on Windows 10 & 11

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 that points to the partition that contains the UEFI boot control file (\EFI\MICROSOFT\BOOT\bootmgfw.efi, In this example, it is partition=G either partition=\Device\HarddiskVolume2 (if you haven’t assigned a drive letter for the EFI partition).

The UEFI bootloader should then pass control to the Windows boot loader file. \Windows\system32\winload.efi Feather partition=C,

bcdbedit: show windows boot manager configuration, check bootmgfw.efi path

reboot your computer (use wpeutil reboot command to reboot from the WinPE environment) and remove the bootable USB flash drive.

Alternative! You can manually perform all the actions performed by the bcdboot command. Next, we’ll show you how to copy the EFI system files and rebuild the BCD itself with the bcdedit command.

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 Boot Configuration Data (BCD) entry in Windows 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 BCD entry created. Use this GUID instead {your_guide} in the following order:

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}

bcdbedit: create boot entry for efi system partition

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 properly the first time, try the following:

  1. Turn off your device;
  2. Unplug (physically) your hard drive;
  3. Turn on your computer, wait until the boot error window appears (an operating system was not found), and turn it off again;
  4. Plug your drive back in.

If this does not help, boot from the installation USB flash drive and run the command:

bootrec /rebuildbcd

restart your computer

bootrec rebuildbcd

Then in our case (tested on a VMWare virtual machine with UEFI firmware), we had to select a new item in the boot menu EFI\Microsoft\Boot\bootmgrfw.efi file on the EFI partition.

In some UEFI menus, by analogy, you need to change the priority of the boot partition.

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

After all these actions, your Windows should boot properly.

tip, If nothing works, it is recommended to make sure that only the EFI partition has the boot flag. You can do this using GParted LiveCD.

In some cases, after recreating the EFI and MSR partitions and reinstalling 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:

  1. Open Power Options in Control Panel powercfg.cpl,
  2. to select Choose what the power button does,
  3. press Change settings that are currently unavailable button and “Disable”enable fast startupoption in the “Shutdown Settings” section.Disable Fast Startup on Windows 10/11

Leave a Comment