The Windows installer sucks
I’m for the most part a Linux user, my main Desktop currently runs NixOS unstable (Definitely going to write about Nix and NixOS in the future, but right now, I need to vent.) Unfortunately, for some things I do (like gamehacking), I need a Windows install around.
So, I go to install a fresh copy of Windows 10 onto my secondary drive and then go to boot back into Linux, oh shit, my Grub is gone!
I’ve dealt with this before so I should’ve known that the Windows installer would do this. But every time, I forget. It’s just such incomprehensibly stupid behavior for an installer to do by default. Why would most users ever want or need their bootloader to be on a different drive.
(Just to be clear: The Windows installer scans all detected drives for any pre-existing suitable partition for the bootloader and then wipes them–without a prompt!)
So, how do we fix this? Well first kick out the Windows bootloader and re-install your Linux one, in my case I used a NixOS live iso and chrooted in with nixos-enter and did a nixos-rebuild.
Afterwards we can boot into a Windows 1X iso, once into the installer press SHIFT+F10
to open a command prompt.
Then we want to run diskpart
and inside of the diskpart CLI we want to:
list disk
# num is the disk that you want to create the bootloader on
select disk <num>
list partition
# num is a partition you want to resize to be smaller
# to create room for the ESP partition
select partition <num>
shrink minimum=512
# this should automatically select the new partition
# to verify, run 'list partition' again
create partition efi
format quick fs=fat32
list volume
# num is the new partition we created
select volume <num>
# letter can be any untaken drive letter
assign letter=<letter>:
exit
Now that we’ve created, formatted, and mounted our new boot partition we can run:
bcdboot C:\Windows /s <letter>: /f ALL
After a reboot, you should have both a bootable Windows and Linux installation once again.