Regenerate Windows boot files in an EFI dualboot system by mounting the FAT32 EFI System Partition, using bcdboot to copy boot binaries from your Windows installation, and manually recreating the necessary directory structure. This method bypasses third-party tools like Ableboot and restores functionality after GRUB corruption or accidental deletion of the EFI partition contents.
Prerequisites and Environment Setup
Before attempting any repair, you must have access to a Windows installation media or a Windows Recovery Environment (WinRE). The process relies on command-line utilities that are standard in modern Windows versions but require specific permissions and correct drive mapping. It is critical to identify which partition is the EFI System Partition (ESP) and which is the actual Windows OS partition. Confusing these two will result in further boot failures or data loss.
You should also ensure that Secure Boot is either disabled temporarily or configured to allow unsigned loaders if you are modifying low-level boot entries, although standard bcdboot operations usually respect existing Secure Boot policies. If your system uses UEFI with Legacy BIOS fallback, this guide assumes pure UEFI mode, as indicated by the tags regarding EFI and bootloader management.
Accessing the Command Prompt
The first step is to launch an elevated command prompt within the recovery environment. Insert your Windows installation USB drive and boot from it. Select "Repair your computer" rather than "Install now." Navigate to Troubleshoot > Advanced options > Command Prompt. Alternatively, if you can still boot into Linux via GRUB, you can use a live Linux environment to mount the partitions and then chroot into Windows if possible, but the native Windows recovery tool is more reliable for generating BCD stores.
Once in the command prompt, verify that you have administrative privileges. You can test this by running whoami; the output should indicate you are part of the Administrators group. Without these rights, you cannot write to the protected EFI partition or modify the Boot Configuration Data store.
Identifying Partitions Correctly
Use the diskpart utility to list all volumes and identify the correct drives. Open diskpart by typing diskpart at the prompt. Inside diskpart, run list vol. Look for a small FAT32 partition, typically 100MB to 500MB in size, labeled as "System" or "EFI." Note its volume number. Then, look for the large NTFS partition where Windows is installed, often labeled "Windows" or "OS."
If the EFI partition is missing entirely from the list, it may have been deleted. In that case, you need to create a new partition formatted as FAT32 and mark it as active. However, most cases involve the partition existing but being empty or corrupted. Assign drive letters to both the ESP and the Windows partition using assign letter=E and assign letter=W respectively, ensuring you do not overwrite existing letters used by other devices.
Recreating the Directory Structure
After assigning drive letters, exit diskpart. The next phase involves creating the specific folder hierarchy that Windows expects for booting. Even if the EFI partition has files, they may be in the wrong location. Create the following directories on the ESP drive (assuming E:): E:\EFI\Microsoft\Boot. Use the mkdir command for each level if they do not exist.
This structure is non-negotiable for Windows UEFI booting. The bootloader looks specifically in \EFI\Microsoft\Boot\BCD for the configuration store. If this path does not exist, bcdboot will fail to place the necessary files correctly. Ensure that the ESP is writable; sometimes file attributes prevent modification, so you may need to clear read-only flags if you encounter permission errors during manual file creation.
Executing bcdboot
The core repair command is bcdboot. Run the following command, substituting W: for your Windows partition letter and E: for your EFI partition letter:
bcdboot W:\Windows /s E: /f ALL
The /s E: parameter specifies the target system partition (the ESP). The /f ALL flag ensures that boot files for both UEFI and legacy modes are generated, providing maximum compatibility. The /l en-us flag can be added if you need to specify language settings, though it is optional. This command copies the boot binaries, creates the BCD store, and registers the entry in the NVRAM.
If you receive an error stating "File \Boot\bcdstore could not be created," verify that the E:\EFI\Microsoft\Boot directory exists and that you have write access. If the error persists, check if another operating system’s bootloader (like GRUB) has locked the partition. You may need to reboot into Linux, unmount the partition, and retry.
Verifying and Finalizing
After successful execution, verify the files exist in E:\EFI\Microsoft\Boot. You should see bootmgfw.efi, bootmgr.efi, and the BCD file. Reboot the system. If the system boots into Windows, the repair was successful. If it fails, check the BIOS/UEFI settings to ensure the Windows Boot Manager is set as the primary boot option.
For users managing multiple OSes, consider reviewing how to manage default boot entries to prevent future conflicts. Understanding the relationship between the EFI partition and the OS bootloader is key to maintaining a stable dualboot setup.
Frequently Asked Questions
What if the EFI partition is completely missing?
If the partition is gone, you must create a new one using diskpart, format it as FAT32, and assign it a drive letter before running bcdboot. You cannot regenerate the partition table entry without creating the physical space first. After creating it, follow the directory structure steps above.
Can I use this method on a MBR system?
No, this method is strictly for UEFI systems. MBR systems use a different boot mechanism involving the Master Boot Record and active partition flags, managed by bootrec.exe instead of bcdboot targeting an EFI partition.
Why did GRUB delete my Windows boot files?
GRUB installations sometimes overwrite the EFI partition root or misconfigure the NVRAM boot order. While GRUB usually coexists peacefully, aggressive cleanup scripts or failed updates can wipe the Microsoft folder. Always backup the EFI partition before major bootloader changes.
Is it safe to delete the old BCD file manually?
It is generally safer to let bcdboot overwrite it automatically. Manual deletion risks leaving orphaned entries in the NVRAM that point to non-existent files, causing boot menu errors. Let the tool handle the cleanup.
How do I fix Secure Boot issues after this repair?
If Secure Boot prevents loading, enter your BIOS/UEFI settings and toggle Secure Boot off, then back on to refresh the keys. Ensure the Windows Boot Manager certificate is trusted. Most modern Windows installations sign their bootloaders correctly by default.