Skip to content

Instantly share code, notes, and snippets.

@leventerevesz
Last active June 17, 2024 05:57
Show Gist options
  • Save leventerevesz/5b4b0a31d74eb80f62c2fb5b087d6d50 to your computer and use it in GitHub Desktop.
Save leventerevesz/5b4b0a31d74eb80f62c2fb5b087d6d50 to your computer and use it in GitHub Desktop.

Recreating the Windows bootloader on a new EFI partition

This guide is for UEFI-GPT Windows installs. Microsoft's bcdboot utility can recreate the bootloader on any selected partition quite easily, and it won't break any existing EFI entries (unlike the bootrec /fixmbr on MBR installs).

This process can be done on a working Windows install, or on the Windows Installer. To access the Command Promt on the Windows Installer, press ShiftF10 after the Windows Setup window appears, or click Next > Repair your computer.

Assign a drive letter to the EFI partition you want to use

You can do this with Disk Managment as well, if you can boot the installed Windows.

Enter diskpart

diskpart

Look at the volumes on your disk. You need to find the Windows volume and the EFI volume. The Windows volume has NTFS filesystem and is usually large in size. The EFI partition is usually between 100MB and 500MB and has FAT32 filesystem.

DISKPART> list volume

  Volume ###  Ltr  Label        Fs     Type        Size     Status     Info
  ----------  ---  -----------  -----  ----------  -------  ---------  --------
  Volume 0         System Rese  NTFS   Partition    350 MB  Healthy    
  Volume 1     C                NTFS   Partition    239 GB  Healthy    Boot
  Volume 2                      FAT32  Partition    500 MB  Healthy    

After you located the EFI volume you want to create the bootloader on, assign the letter S to that volume.

Use the appropriate volume number!

DISKPART> select volume 2
DISKPART> assign letter=S

Look at the volumes again, to make sure the desired partition got the S letter.

DISKPART> list volume

Exit diskpart.

DISKPART> exit

Create the EFI files in S:

We are using the bcdboot utility. The first parameter is the Windows folder. The /s flag lets you specify the destination EFI drive.

If you are doing this from the Windows installer USB, the drive letter of the Windows drive will not be C:. Substitute the correct drive letter.

bcdboot C:\Windows /s S:

This creates the bootloader on the selected partition. You can reboot now, and the UEFI will hopefully find the Windows Boot Manager.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment