2.2 KiB
EFI notes
Dual Boot
We can use the EFI NextBoot
feature to signal that the system should boot the 2nd OS.
For initial setup, find the 2nd OS boot entry:
PS C:\Users\pleb\Documents\windows-scripts> PowerShell.exe -ExecutionPolicy Bypass -File .\List-BootEntries.ps1
Found Boot0000
Found Boot0002
Hard-code the boot entry in the Set-BootNext.ps1
script:
# NixOS boot entry ID
$NixOSBootEntryID = "0002"
Then whenever you want to run NixOS, run the script:
PowerShell.exe -ExecutionPolicy Bypass -File \Users\pleb\Documents\windows-scripts\Set-BootNext.ps1
EFI Recovery
Sometimes Windows Update will trample the EFI boot entry for NixOS.
Linux
-
Boot into a NixOS live environment (USB or CD).
-
Mount your NixOS root partition and the ESP (EFI System Partition):
mount /dev/nvme0n1p4 /mnt mount /dev/nvme0n1p1 /mnt/boot
-
Chroot into your NixOS installation:
nixos-enter --root /mnt
-
Manually reinstall the bootloader:
bootctl install --path /boot
-
Exit the chroot environment:
exit
-
Unmount the partitions:
umount /mnt/boot umount /mnt
- Ensure the boot order is to your satisfaction
efibootmgr -v
efibootmgr -o XXXX,YYYY
- Reboot your system.
By following these steps, you should be able to recover your NixOS boot option if it disappears after a Windows update.
Windows
In the unlikely scenario that the Windows boot entry is removed, here's how to recover from that:
-
Mount the EFI System Partition if it's not already mounted:
mount /dev/nvme0n1p1 /mnt/boot
(Replace nvme0n1p1 with the correct partition if different)
-
Verify that the Windows bootloader files exist:
ls /mnt/boot/EFI/Microsoft/Boot/
You should see a file named
bootmgfw.efi
. -
If the files are present, you can create a new boot entry for Windows using
efibootmgr
:efibootmgr -c -d /dev/nvme0n1 -p 1 -L "Windows" -l '\EFI\Microsoft\Boot\bootmgfw.efi'
This command creates a new boot entry labeled "Windows" that points to the Windows bootloader file.
-
Verify that the new entry was created:
efibootmgr -v