Fixing Windows bootloader after installing Linux (dual-boot)
Windows does not like it when you install Linux after it
Table of contents
Context
I had been running a dual-boot system for 2 years since my current PC was first built. I have one NVMe drive running Windows 11 and another NVMe drive running Fedora. This was a way for me to separate my Linux workstation from my Windows gaming drive. However, I would eventually do all development work on Windows anyway.
So, I decided to spice things up and try out Kubuntu, a super customizable flavor of Ubuntu, and do a fresh install. The installation went well, but something went wrong on reboot.
Problem
Upon rebooting, I noticed that my Windows boot had gone missing. The only bootable disk I had listed in BIOS was my newly installed Kubuntu. So, I tried changing the boot settings to see if there were other available boot options. I found a few leftover Windows boot partitions from my storage drives that I forgot to clear, but those weren't the drives I needed to boot to. I spent several hours during the weekend searching for a solution and finally found one.
Repair Windows EFI Partition After a Linux Installation
Solution
Prepare Windows 11 installation media on a USB drive and boot to it.
Start Windows 11 installation process, but click the following links to open a command prompt.
Repair your computer -> Troubleshoot -> Advanced -> Command Prompt
- Run
diskpart
in the command prompt
C:\Users\user>diskpart
Microsoft DiskPart version 10.0.22621.1
Copyright (C) Microsoft Corporation.
On computer: YOUR-COMPUTER-NAME
DISKPART>
- Run
list vol
to list the volumes and note the letter of the drive you want to boot into
DISKPART> list vol
Volume ### Ltr Label Fs Type Size Status Info
------------ --- ------------- ----- ---------- ------- --------- --------
Volume 0 F SSD Storage NTFS Partition 931 GB Healthy
Volume 1 D Old 1TB HDD NTFS Partition 931 GB Healthy
Volume 2 E New 2TB HDD NTFS Partition 1863 GB Healthy
Volume 3 C Game Drive NTFS Partition 931 GB Healthy
Volume 4 NTFS Partition 701 MB Healthy System
- If the volumes you want aren't assigned a letter, assign them like so
DISKPART> sel vol 3
DISKPART> assign letter=C
- C drive is what I want, so I can exit
diskpart
now
DISKPART> exit
C:\Users\user>
- Run
bcdboot
to copy the Windows boot files from C drive onto itself, in both UEFI and BIOS formats. You can also copy the boot files to another drive if you wish.
C:\Users\user> bcdboot c:\Windows /s c: /f ALL
After doing this, I was able to boot to my Windows drive from BIOS.