DEV Community


Posted on • Updated on

Restore Windows UEFI boot


Sometime last week, I decided to move my entire ESP folder into a dedicated boot partition mounted at /boot. (I did this because I liked the idea of having everything boot-related in a partition for easy access when I dual boot or need any file from there). Unfortunately, I didn't attempt to reboot in order to check if anything was broken...until today

Windows boot is broken...

And by "broken", I mean that in the rEFInd boot menu, there was nothing showing for windows. It only showed my linux installation.

At first, I was sure this was an easy fix and all I had to do was boot from a linux disk image, and run the commands:

hand holding wrench

mount /dev/sda3 /mnt
mount /dev/sda1 /mnt/boot
refind-install --root /mnt
Enter fullscreen mode Exit fullscreen mode

...unfortunately, that didn't work :(. Attempting to boot directly from Windows Manager also didn't work, so at this point I knew something had gone very wrong.

As my sunday evening grew into sunday night, I decided to actually stop being lazy with this fix, and discover why windows was being soo elusive.

Steps to recovery

Using the steps outlined in the arch wiki for rEFInd, I was able to get my hands on an EFI shell. Using some of the commands from the arch wiki, I was able to discover that the windows boot EFI file didn't exist anymore in the boot partition.

output of the command bcfg boot dump -v
output of bcfg boot dump -v

Well that explains a lot!

Both rEFInd and Windows boot manager expected to find a \EFI\Microsoft\Boot\bootmgfw.efi file, but it wasn't finding it, so the boot never worked.

Step 1. Add bootmgfw.efi to rEFInd

Boot into Linux and mount your windows partition, then copy the existing file into where rEFInd was expecting to find it.

sudo mkdir -p /boot/EFI/Microsoft/Boot
sudo cp /run/media/smac89/Windows/Windows/Boot/EFI/bootmgfw.efi /boot/EFI/Microsoft/Boot
Enter fullscreen mode Exit fullscreen mode

At this point, you will see the blue windows logo from the rEFInd boot menu, but attempting to boot from it may result in the following screen:

Windows failed to start

...if so, continue to the next step

Step 2: Get access to a windows terminal

There are many ways to do this. Pick the one that is most convenient, and proceed.

Inside the terminal type the commands:

list volumes
Enter fullscreen mode Exit fullscreen mode

Find the volume containing the boot partition, and assign it a label if it doesn't have one:

select volume N
assign letter=m
Enter fullscreen mode Exit fullscreen mode

Exit diskpart

Enter fullscreen mode Exit fullscreen mode

Finally, we use the following command to install windows boot entries to the boot partition:

bcdboot C:\Windows /l en-US /s m: /f ALL
Enter fullscreen mode Exit fullscreen mode

After running the above command, the boot partition now contains all the entries needed to boot windows.


Thanks for reading.

Top comments (0)