How Do I Get Deleted Boot Option Back
In this article 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 article 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.
Contents:
- GPT Hard Disk Partition Structure in Windows
- Missing EFI Partition in Windows
- How to Manually Create EFI and MSR Partitions on GPT Drive?
- Repair the EFI bootloader and Windows BCD
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).
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.
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.
Run the disk and partition management tool:
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.
Select this disk:
Display the list of partitions on the disk:
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).
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 article.
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:
And delete it:
Delete partition override
Delete partition override
Make sure that there is only 9GB Windows partition left (in our case):
Now you can re-create EFI and MSR partitions manually. To do it, run these commands in diskpart context one by one.
Select the disk:
Create a 100MB EFI partition, format it with FAT32 file system and assign a drive letter to it:
create partition efi size=100
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
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
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
select vol 1 assign letter=C exit
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
mkdir G:\EFI\Microsoft\Boot xcopy /s C:\Windows\Boot\EFI\*.* G:\EFI\Microsoft\Boot
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
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.Iin the next command put this GUID instead of {your_guid}.
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 /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
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
Restart your computer… In our case it didn't boot from the first time. Try the following:
- Turn your PC off;
- Unplug (physically)your hard drive;
- Turn your PC on, wait till the boot error window appears (An Operating System not found) and turn it off again;
- 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.
After all these actions, your Windows should boot correctly.
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.
How Do I Get Deleted Boot Option Back
Source: http://woshub.com/how-to-repair-deleted-efi-partition-in-windows-7/
0 Response to "How Do I Get Deleted Boot Option Back"
Post a Comment