7

Recently, after I've done something to my multiboot system, when I boot NixOS with systemd-boot, boot menu does not show up anymore even though the timeout is still set to 2 seconds in /loader/loader.conf (on the ESP):

# /loader/loader.conf on the ESP
timeout 2
default nixos-generation-380

Here is what I have in my /etc/nixos/configuration.nix:

{ # ...
  boot.loader = {
    efi.canTouchEfiVariables = true;
    systemd-boot.enable = true;
    timeout = 2;
  };
}

It turned out that to see the boot menu, I had to press down some key during start-up, as if the timeout had been set to 0 (instead of 2) seconds.

I tried removing systemd-bootx64.efi from the ESP and re-installing NixOS with nixos-install from a USB flash drive. This restored systemd-bootx64.efi but did not bring back the boot menu.

It seems that this problem is not completely uncommon:

Both issues are reported to be solved. However, I did not understand the first solution:

Edit 3: SOLVED! Reinstalling the UEFI did the trick.

What does it mean to "reinstall the UEFI"?

As to the second, it suggests to use t and Shift+t keys in the boot menu (which shows up if some key is pressed down during the start-up) to set a different timeout, but I do not want just a different timeout, I want systemd-boot to respect the settings in /loader/loader.conf.

So, my question was: how to make systemd-boot use again the settings from /loader/loader.conf?

I am editing this question after I've found the solution, and I am going to post my answer now.

Alexey
  • 1,868
  • 4
  • 20
  • 35
  • Have you tried adjusting the timeout? The default value is 5, but you can also set it null to disable the timeout entirely. Regarding your triple-boot system, which EFI boot manager are you using? Is it possible that NixOS kernel is being booted via a boot manager other than the systemd-boot provided by NixOS? – Emmanuel Rosa Jul 30 '18 at 22:31
  • Your EFI setup looks OK. In your ESP you should have (/boot)/loader/loader.conf, which is your main systemd-boot configuration. What does it look like? You should see your timeout setting from /etc/nixos/configuration.nix reflected in loader.conf. – Emmanuel Rosa Jul 31 '18 at 10:49
  • @EmmanuelRosa, i've found a solution, so i am cleaning up the comments. – Alexey Aug 04 '18 at 22:33

1 Answers1

4

After reading comment #6 on "systemd-boot, no timeout, no select menu - LoaderEntryDefault" and looking at "systemd-boot sets efivar LoaderEntryDefault, which overrides default in /boot/loader/loader.conf" nixpkgs issue on GitHub, I've figured out that the issue was probably caused by EFI variables which somehow got set and were overriding the settings from /loader/loader.conf.

Indeed, there were these two variables set that were causing trouble:

§ cat /sys/firmware/efi/efivars/LoaderConfigTimeout-4a67b082-0a4c-41cf-b6c7-440b29bb8c4f
0

and

§ cat /sys/firmware/efi/efivars/LoaderEntryDefault-4a67b082-0a4c-41cf-b6c7-440b29bb8c4f
nixos-generation-374

(I've made up the value '374' here: it only matters that it was different from the one in /loader/loader.conf at the time when I inspected it.)

The list of EFI variable used by systemd-boot can be found at the end of "systemd-boot UEFI Boot Manager" page on Freedesktop Wiki:

LoaderEntryDefault      entry identifier to select as default at bootup                  non-volatile
LoaderConfigTimeout     timeout in seconds to show the menu                              non-volatile
LoaderEntryOneShot      entry identifier to select at the next and only the next bootup  non-volatile
LoaderDeviceIdentifier  list of identifiers of the volume the loader was started from    volatile
LoaderDevicePartUUID    partition GPT UUID of the ESP systemd-boot was executed from     volatile

To remove LoaderEntryDefault-[...] variable it was enough to press d key twice in the boot menu: to set and unset a new value.

To remove LoaderConfigTimeout-[...] variable it turned out enough to press Shift+t enough times to set the timeout to 0, plus one more time.

This resolved my problem. Here is a related question I asked on Superuser.SE about safely modifying EFI variables in general.

Alexey
  • 1,868
  • 4
  • 20
  • 35
  • It was so unexpected that UEFI stores that default value. And it was so simple to select a new default)) Thanks for your research! – Nikita Hismatov Sep 01 '21 at 14:11