DEV Community

Valentin Boettcher
Valentin Boettcher

Posted on • Edited on

Fixing Linux Dualboot: Reinstalling the Windows EFI Bootloader Files

Note to my future self :).

Reloading my Linux install after a pretty radical 'nuke and pave' I had to get my Windows dualboot back to work.
There are a thousand guides on how to do that, but I'll add another one in case your setup is similar to mine.

I have installed windows on a separate drive and Linux on my main drive, along with the efi partition.

Don't follow this guide blindly. Think about every step you take, because you can seriously mess up your system :).

With that out of the way, the things you have to do are:

  1. Boot a windows install medium.
  2. Choose your language and enter the 'repair options'.
  3. Go to advanced and select 'command line'.
  4. To mount the efi partition type diskpart and in diskpart then type list volume. A list of volumes will be printed and one of them the efi partition (usually around 500mb ). Select this partition (select volume [number]) and assign a drive letter (X is the drive letter you assign).
  5. Check where your windows partition is mounted. The diskpart list volume output will probably include it. I will assume that it is volume C. Exit diskart with exit.
  6. To finally install the boot files type the command bcdboot c:\windows /s x: . This will generate boot files based on c:\windows and install them on the partition with the letter X .

Thats it, you can reboot now.
You may have to reconfigure grub (or whatever loader you use). On arch-linux, make sure you have os-prober installed :).

Top comments (5)

Collapse
 
danielm profile image
Daniel Mejía Raigosa

Thank you, tried this and still worked to recover an EFI partition for Window 11 after formatting the EFI partition in my Debian 11. Thank you for taking the time to write this

Collapse
 
nicolasin profile image
Nicolasin

Thanks for this buddy, just got a fatal error on a Linux install and eh what to do, it'll be ok, have a fun day! ;D

Collapse
 
blackcatdevel0per profile image
Asadbek Sayfiev

Big thanks!

Collapse
 
groudfrank profile image
Groud Frank

LOL, not the clearest set of instruction but it definitely helped me out so thank you! You saved me a lot of work. You neglected to mention that you have to exit out of diskpart with the command 'exit' and then run the bcdboot command. Also, 'bcdboot c:\windows /s x' produced an error for me that said something like "BFSVC: Failed to set element application device. Status = [c00000bb]" and another I'm too lazy to try and find. There should be a colon at the end of 'x', i.e. the efi partition that was assigned a new letter in this tutorial. The command should look like this:

bcdboot c:\windows /s x:

Collapse
 
geekyarthurs profile image
Mahesh C. Regmi

Dude you're life saver!
Thank you so so so much.