I wanted to drop an update mainly to record the solution for posterity but also for thanking all those who took the time to respond and help me out because I got some critical pointers that way without which I would have been lost. There are a lot of similar posts on Windows’ support website but they feel like they have been written by customer service people who just ask you to reinstall Windows or by illiterates. There is never an attempt to give any reason behind their suggestions.
This post and its crosspost is what I am referring to: https://lemmygrad.ml/post/6734778
Long story short, I have a dual boot Linux and Windows setup. I
reinstalled my Linux OS to try out NixOS, went back to Void. But since
installing NixOS, neither rEFInd nor GRUB was able to find the Windows
installation. This is what the disks’ layout looked like throughout
the process. nvme1
houses the Linux install and the other disk has
Windows.
$ lsblk -f
NAME FSTYPE FSVER LABEL [...] MOUNTPOINTS
nvme1n1 zfs_member 5000 zroot [...]
├─nvme1n1p1 vfat FAT32 [...] /boot/efi
├─nvme1n1p2 swap 1 [...] [SWAP]
└─nvme1n1p3 zfs_member 5000 zroot [...]
nvme0n1
├─nvme0n1p1
└─nvme0n1p2 ntfs
At the time of the original post, I had mistakenly assumed that
Windows had its own partition related to booting somewhere. I made
this assumption because Windows engages in a lot of proprietary
weirdness. This was incorrect. The files pretaining to booting Windows
were located in nvme1n1p1
alongside the Linux boot files. In the
process of installing Linux, I had reformatted nvme1n1p1
because of
which Windows’ boot files were lost. The fix for this boiled down to
restoring these lost files and running {grub,refind}-install
so that
a boot entry for Windows was added by the respective bootloader.
Before this, I had another problem at my hands. Somehow I had made
nvme1n1
use a MBR partition table. Because of this, I could not
follow any guides that used a Windows recovery media to install the
boot files. I don’t know how that happened because I always use GPT.
So I had to reformat the disk and install the operating system again.
I should have saved a ZFS snapshot and restored from it to avoid a lot
of headache but in my panicked state I forgot to do that and had to
reinstall and set up Void Linux from scratch.
Then I followed this guide that I found in a Windows support thread reply: https://woshub.com/how-to-repair-deleted-efi-partition-in-windows-7/
For some reason, Windows did not accept that nvme1n1p1
was a valid
EFI partition. So I had to reformat this partition using the diskpart
tool that is available in Windows’ command prompt. The series of
commands looked something like this:
diskpart
list disk
select disk 1
list partition
select partition 1
delete partition
create partition efi size=512
select partition 1
format quick fs=fat32 label="System"
assign letter=P
exit
Deleting and recreating partition 1 may have been unnecessary. But
since the command for creating it contained efi
in it I didn’t want
to take chances.
The Windows drive was already mounted at C:\
. So I ran this command:
bcdboot c:\windows /s P: /f UEFI
This copied the Windows boot files and made Windows Boot Manager the top entry in the boot order. Now I was able to boot into Windows but not into Linux since rEFInd had been wiped in the process.
Then I had to create a Linux recovery media and reinstall rEFInd. Now rEFInd was able to detect Windows and add an entry for it in the bootloader.
All was good in heaven and on Earth.
Thanks everyone for the help again.
Glad you got it sorted, and I’m sorry I missed your post. But one thing I might mention for future reference, is that it IS possible to upgrade in place from MBR to GPT.
I’ve been dealing with a lot of this sort of thing myself in the last week. I had a catastrophic hardware failure in my desktop that necessitated a large amount of upgrades a bit earlier than planned. This resulted in shuffling of surviving hardware and hard drives between my desktop and server. One part of this is that my server is moving from a 1st gen i5 to a 14th gen i3, and a m.2 SSD for the root partition. I wanted to keep the root partition intact, and upgrade to GPT/UEFI while I’m at it. So I’ve been doing a lot of reading. Definitely not trivial problems, especially when you have to worry about windows too (I’m taking this opportunity to delete windows as well).