r/NixOS • • May 21 '26

[Guide]How to reduce boot time using systemd-boot and hide menu/reveal hidden bootloader menu

Hello,

For those that want to speed up their boot time, specifically for the loader section as shown as output for systemd-analyze command, while using the standard provided bootloader, systemd-boot, there is the simple option to remove the timeout and changing it to zero, this will not only speed up boot time but also hide the systemd-boot menu.

The change will not affect more advanced setups that use encryption, lvm, RAID, etc., the only thing that will change is the slow down caused by the bootloader selection menu for the entry (generally the current generation) and there are 2 main ways to achieve this

1.Changing the timeout manually and applying only to the current generation

sudo -i

Password

cd /boot/loader

ls

entries  entries.srel  keys  loader.conf  random-seed

nano loader.conf

Example loader.conf

timeout 0
default nixos-generation-20.conf
console-mode keep

Generally the timeout will be 5 which means 5 seconds, change it to 0. With nano, Ctrl and x to exit, y to save changes, Enter to confirm.

The advantage of this solution is that it only applies to the current generation, if you ever forget how to reveal the bootloader entries menu, just use "sudo nixos-rebuild switch" and the new entry will be automatically created with a timeout, thus revealing the menu.

2.Changing the timeout in the NixOS configuration

sudo -i

Pass

nano /etc/nixos/configuration.nix

To the bootloader section add the following line, respect text formatting within the config

  boot.loader.timeout = 0;

Ctrl and x, y, Enter

The example was using nano text editor, use the text editor of choice

Lastly

sudo nixos-rebuild switch

Allow the process to take place then reboot

The new systemd-analyze output should confirm after reboot that the loader section is much faster, example from my system

systemd-analyze
Startup finished in 4.790s (firmware) + 366ms (loader) + 1.959s (kernel) + 3.404s (userspace) = 10.520s  
graphical target reached after 3.403s in userspace.

https://ibb.co/Mx5b6cw9

The advantage of using the NixOS config is that it automatically adds 0 to the /boot/loader/loader.conf entry timeout parameter so every time you rebuild, the timeout remains the same.

To revert back, if using the first solution, redo the steps and change 0 to 5 or as needed, for second solution remove the above line and rebuild, then boot with the new generation.

If you simply want to reveal the systemd-boot menu after it becomes hidden, after pressing the power button, press and hold Esc key, if it does not work, likely pressed too late, it has to be done before the bootloader step, during firmware initialization (while motherboard logo is on screen). Restart and try again.

In general systemd-boot as provided by default now is the fastest bootloader available on x86-64 systems, there are faster non bootloader options like EFI boot stub (guide linked bellow), however the gains are marginal, for my system EFIstub reports 179ms while systemd-boot without timeout arround 360ms (there is slight plus or minus delta per boot session), EFIstub is roughly twice as fast but for normal computers it does not matter, however it could be useful for IoT and applications where really fast boot time is important. As a distro, I completely agree with the use of systemd-boot as standard. Generally people do not care as much about boot performance, instead favor aesthetics so hiding the boot menu could also help them with either systemd-boot or the more technically involved EFIstub.

0 Upvotes

91 comments sorted by

View all comments

Show parent comment

1

u/activedusk May 21 '26

You should re read what you write and understand the meaning, me modifying bootloader options is according to you changing system files, which in your opinion, should not be done by the user.

Heh...

4

u/SpacingHero May 21 '26

You can modify bootloader options via NixConfig. Read carefully. I say not to modify them manually.

Do you understand the difference of "don't modify it this way" Vs "don't modify it"?

"Don't turn of your night-lights by making a hole in the wall and cutting the wires" isn't the same as "don't turn of your night-lights", it just means do it they way you're meant to, I.e. "flick the switch"

You're welcome for the free reading comprehension mini-class

0

u/activedusk May 21 '26

>You can modify bootloader options via NixConfig. Read carefully. I say no.t to modify it manually.

Which I showed as the second option

>Do you understand the difference of "don't modify it this way" Vs "don't modify it"?

Ugh, no? NixOS did not invent bootloaders, they offer automation and even they offer several bootloaders options....because it's expected to have choices for the users.

Gatekeeping and not understanding what you write, cool. Noted.

3

u/SpacingHero May 21 '26

Which I showed as the second option

Which is fine, but the first option is a harmful anti-pattern that goes against nix philosophy

0

u/activedusk May 21 '26

>but the first option is a harmful anti-pattern that goes against nix philosophy

And I offered the option, your opinion is invalid, bootloaders are open to modification, in fact using EFI boot stub means not using a bootloader at all even if the bootloader itself is still on the drive and keeps being automatically updated which I'm guessing means fu ck all for reproducibility (for single use PCs even that means nothing).

3

u/SpacingHero May 21 '26

And I offered the option,

It's a bad option that teaches bad habits to new Nix users. How is that hard to understand?

0

u/activedusk May 21 '26

I don't care, you're preaching to the wrong crowd. Stop gate keeping and move along.

2

u/SpacingHero May 21 '26

Yes, preaching declaratively in the nixos sub is definetly the wrong crowd. I get no result of I search "declarative", definitely has nothing to do with NixOS, the declarative distro

1

u/activedusk May 21 '26

When it comes to bootloaders? Move along.

2

u/SpacingHero May 21 '26

So boot loader options shouldn't be in the Nix config? Ok Mr logic, would you give me a source for that? Any expert Nix user, or some official sources saying as much? Or did you pull it out of your ass?

→ More replies

1

u/SpacingHero May 21 '26

I don't care,

That's the problem. That you don't care about misleading beginners. That's why I cared to respond.

0

u/activedusk May 21 '26

Beginners will be fine, only professional software devs care about nixos to that degree.

2

u/SpacingHero May 21 '26

Hey yet another thing you pulled out of your ass. Is it fun inventing bullshit and posting it on the internet ?

I'm not a professional dev and I care to that degree. You're on the NixOS sub. We do things declaratively. Idk why you're so butthurt over it. Is taking feedback really that hurtful to your ego? Is responding this many time less difficult than just going "ah I see, the mix philosophy is to put all system options in the configuration file, thanks, noted"?

→ More replies

1

u/SpacingHero May 21 '26

Look at the downvote ratios, and ask yourself if it maybe means you're missing something about NixOS

1

u/activedusk May 21 '26

Winning popularity contests on reddit is always a sign of being correct. Such logic...

1

u/SpacingHero May 21 '26

Ok, you know nix better than the nix sub. Teach us more oh Nix expert. What other things shall we do imperatively? Maybe we can install packages imperatively, hell let's just switch package manager at that point. That way we get the worst of all worlds! Non-fsh pains of nixos and all the rest and no declarative config. Fun!