Nixos EFI boot does not detect windows anymore

Hey all,

I have a habit of updating my nixos before any reboots. So i did the rebuild switch step and rebooted. Booted into windows and apparently there was a pending update on Windows which when finished, rebooted my PC. Once i got into my linux bootloader, i got no entry for Windows.

Started checking around:

[ -d /sys/firmware/efi/efivars ] && echo "UEFI" || echo "fail"
UEFI
sudo nixos-rebuild --install-bootloader switch
[sudo] password for mav:
building Nix...
building the system configuration...
Copied "/nix/store/jimz0md5q3l7w1nrgd2j3bi1w9l6da7l-systemd-250.4/lib/systemd/boot/efi/systemd-bootx64.efi" to "/boot/efi/EFI/systemd/systemd-bootx64.efi".
Copied "/nix/store/jimz0md5q3l7w1nrgd2j3bi1w9l6da7l-systemd-250.4/lib/systemd/boot/efi/systemd-bootx64.efi" to "/boot/efi/EFI/BOOT/BOOTX64.EFI".
Random seed file /boot/efi/loader/random-seed successfully written (512 bytes).
Created EFI boot entry "Linux Boot Manager".
activating the configuration...
setting up /etc...
reloading user units for mav...
setting up tmpfiles

Still no windows in there.

df -h
Filesystem      Size  Used Avail Use% Mounted on
devtmpfs        3.2G     0  3.2G   0% /dev
tmpfs            32G   15M   32G   1% /dev/shm
tmpfs            16G  8.6M   16G   1% /run
tmpfs            32G  432K   32G   1% /run/wrappers
/dev/nvme1n1p1  916G  436G  434G  51% /
/dev/nvme0n1p1   96M   47M   50M  49% /boot/efi
/dev/nvme0n1p3  931G  732G  200G  79% /run/media/mav/windows
/dev/sda        916G  512G  359G  59% /run/media/mav/sd1
tmpfs           6.3G   32K  6.3G   1% /run/user/1000

Apparently, my windows partition is mounted on nvme1n1p3 so no problem there.

Double checked my configs and all seem to be in order:

imports =
    [
      # Include the results of the hardware scan.
      ./hardware-configuration.nix
    ];

  # Bootloader.
  boot.loader.systemd-boot.enable = true;
  boot.loader.efi.canTouchEfiVariables = true;
  boot.loader.efi.efiSysMountPoint = "/boot/efi";
  boot.supportedFilesystems = [ "ntfs" ];
  fileSystems."/run/media/mav/windows" = {
    device = "/dev/nvme0n1p3";
    label = "Windows";
    fsType = "ntfs";
    options = [ "rw" "uid=1000" ];
  };
  fileSystems."/run/media/mav/sd1" = {
    device = "/dev/sda";
    fsType = "auto";
    label = "SD1";
    options = [ "defaults" "user" "rw" "auto" ];
  };

Not much in my hardware-configuration.nix either:

āžœ cat -p /etc/nixos/hardware-configuration.nix
# Do not modify this file!  It was generated by ā€˜nixos-generate-configā€™
# and may be overwritten by future invocations.  Please make changes
# to /etc/nixos/configuration.nix instead.
{ config, lib, pkgs, modulesPath, ... }:

{
  imports =
    [ (modulesPath + "/installer/scan/not-detected.nix")
    ];

  boot.initrd.availableKernelModules = [ "vmd" "xhci_pci" "ahci" "nvme" "usbhid" "usb_storage" "sd_mod" ];
  boot.initrd.kernelModules = [ ];
  boot.kernelModules = [ "kvm-intel" ];
  boot.extraModulePackages = [ ];

  fileSystems."/" =
    { device = "/dev/disk/by-uuid/32a9a971-79f6-4f11-9d1e-fdaf9b51cb02";
      fsType = "ext4";
    };

  fileSystems."/boot/efi" =
    { device = "/dev/disk/by-uuid/4E76-5B21";
      fsType = "vfat";
    };

  swapDevices = [ ];

  # Enables DHCP on each ethernet and wireless interface. In case of scripted networking
  # (the default) this is the recommended approach. When using systemd-networkd it's
  # still possible to use this option, but it's recommended to use it in conjunction
  # with explicit per-interface declarations with `networking.interfaces.<interface>.useDHCP`.
  networking.useDHCP = lib.mkDefault true;
  # networking.interfaces.enp6s0.useDHCP = lib.mkDefault true;
  # networking.interfaces.wlo1.useDHCP = lib.mkDefault true;

  powerManagement.cpuFreqGovernor = lib.mkDefault "powersave";
  hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware;
  # high-resolution display
  hardware.video.hidpi.enable = lib.mkDefault true;
}

I am unable to figure out why the EFI bootloader wonā€™t show the Windows option in the menu.

What can i do to restore back Windows back into the bootloader?

Maybe the Windows update did something strange on the uefi entriesā€¦ Do you still have a UEFI entry in the ā€œBIOSā€ menu (depending on the hardware, the one you get when you press ESC or F12 or ā€¦) and can you still manually boot on Windows by selecting that file?

1 Like

I tried doing by setting the boot priority for the windows partition but thatā€™s always taking me back to the systemd boot menu.

  • Do you have a photo? Because as far as I know in UEFI you typically donā€™t prioritize partitions but UEFI entriesā€¦ So maybe the UEFI list is taking precedence over the order of partitions (Iā€™m not a UEFI expert so it may not make much sense), Check in all tabs in you can see the list of UEFI entries detected by the system, and try to press ESC at boot (on some computers, like some Asus and DELLs it prints directly the list of bootable UEFI entries that you can boot without changing the priority order you would get with F12/ā€¦).

  • Also, can you maybe give here the list of files you get with tree /boot? If you see some .efi entries belonging to windows (I think they are typically called bootmgfw.efi if Windows), it might be worth trying to boot them directly via grub if you canā€™t find them in the bios menu.

  • Can you also give us the list of entries given in

    $ nix-shell -p efibootmgr
    $ sudo efibootmgr -v
    

    ?
    If you see an entry in Windows you can temporaly boot to it by default using:

    sudo efibootmgr -n <hex_value_of_entry>
    

I was able to boot through a windows boot device to my installed windows. Seems like there was an upgrade that did not completed and then once its been completed i was able to restore the nixos boot loader.

So Iā€™m not sure to get it: itā€™s working now?

Yea, all good. Thanks @tobiasBora for the ideas