u/activedusk

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

[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.

https://www.reddit.com/r/NixOS/comments/1thifji/guidehow_to_create_efi_boot_stub_on_nixos/?utm_source=share&utm_medium=web3x&utm_name=web3xcss&utm_term=1&utm_content=share_button

u/activedusk — 21 hours ago
▲ 3 r/NixOS

[Guide]How to create EFI boot stub on NixOS

Hello,

For those that want to speed up their boot time, specifically for the loader section as shown as output for systemd-analyze command, one of the options available is to create EFI boot stub entry and while there are several ways using different packages or UEFI shell commands, this guide will cover only efibootmgr.

Warning, before proceeding save important files, if any and have a bootable media prepared with NixOS in case you need to troubleshoot or reinstall. Also after creating the EFIstub boot entry, it is static, meaning any update/nixos-rebuild switch commands that changes the kernel version or initrd will require the user to remake the entry using the new files or the system will either not boot properly or if it does boot it might cause issues due to packages versions used, in some cases it might still work but it is an unstable solution, remake the EFIstub with new bzImage and initrd files.

Disclaimer, this guide does not cover encryption, secure boot, lvm, RAID or other more niche configurations, adapt the steps and commands for more advanced setups.

Also note from the name EFI stub, it's not going to work with legacy BIOS, also have not tested with motherboards with CSM set to BIOS/Legacy instead of UEFI, if you have such a feature set it to UEFI, UEFI only or turn off compatibility feature.

With the warnings and disclaimer out of the way, I should first quantify the gains, note this is with kernel 7.0.5

systemd-analyze
Startup finished in 4.814s (firmware) + 181ms (loader) + 2.063s (kernel) + 3.380s (userspace) = 10.438s  
graphical target reached after 3.379s in userspace.

https://ibb.co/QjfcKB4K

Focus on the (loader) section of the output, in my case it's 181ms or 0.181 seconds which is close to the limit of what's available on x86-64 hardware, possibly ARM or RISC V based motherboards and CPUs can boot faster for this step but not on "normal" desktop or laptops available in 2026. A similar result can be obtained using UKI or possibly other methods of creating an EFI stub (not to be confused with the kernel variable with which it was compiled, warning if you compile your own to enable it, generic distro kernels tend to have it enabled by default, EFI stub in this context refers to the boot entry).

Step 1 - add efibootmgr to your package list

In this example I use nano, replace with your text editor of choice

sudo -i

nano /etc/nixos/configuration.nix

In the "environment.systemPackages = [" add or depending on syntax pkgs.efibootmgr, as per nixos website

https://search.nixos.org/packages?channel=25.11&query=efibootmgr#show=efibootmgr

After making modifications to the config opened with nano, close and save changes, in this case Ctrl and X, y and Enter

Now rebuild and after this do not rebuild again until you have created the EFI stub boot entry and used it, note again that rebuilding or updating afterwards invalidates the in use EFI stub and needs to be remade, (assuming sudo -i is still active)

nixos-rebuild switch

Wait for the process to finish and reboot with the latest generation, now efibootmgr package is available and can begin.

Step 2 - gather parameters in a text file to build the efibootmgr command

I would recommend first writing this into a text file and editing it with your system's information as it has to match your computer exactly.

Find UUID for your root partition, path to initrd, path to init system and kernel parameters. On NixOS all of these can be found in one place with command

cat /proc/cmdline

You could also open file manager, go to / then open proc folder and finally cmdline file, once opened select everything, copy and paste it to your text file.

For general knowledge and for other distros, root partition UUID can be obtained with command

sudo blkid

While the kernel, aka bzImage or more commonly vmlinuz and initrd.img or initramfs.img is usually located inside /boot, to make an EFI stub for more normal distros, create an EFIstub folder inside esp with path like /boot/EFI/EFIstub or if the boot parition has mountpoint /boot/efi, path will be /boot/efi/EFI/EFIstub and copy from boot the vmlinuz and corresponding initramfs.img and use efibootmgr --create command to point to these files, generally the init=path is not a requirement on normal distros, NixOS is just different. Note to use sudo -i or equivalent (on Arch base su is sufficient, on Debian sudo -i or sudo su) before creating or copying files inside boot partition.

Step 3 - finalize efibootmgr command

sudo efibootmgr --create --disk /dev/sda --part 1 --label "EFISTUB" --loader '\EFI\nixos\bzImage.efi' --unicode 'root=UUID=452524-23423 initrd=\EFI\nixos\initrd.efi init=/nix/store/...25.11/init rw loglevel=0 lsm=landlock,yama,bpf'

Note the text box scrolls horizontally, here it is again, remember it is supposed to be one continuous line with only a single space between sections

sudo efibootmgr --create --disk /dev/sda --part 1 --label "EFISTUB" --loader '\EFI\nixos\bzImage.efi' --unicode 'root=UUID=452524-23423 initrd=\EFI\nixos\initrd.efi init=/nix/store/...25.11/init rw loglevel=0 lsm=landlock,yama,bpf'

To explain the syntax

sudo efibootmgr #self explanatory it requires admin privilege and uses efibootmgr package

--create #tells efibootmgr to make new boot entry

--disk #it points to the disk where the boot partition is first as an entire disk in this example /dev/sda, note the space between them and then the partition for following values

--part 1 #again tells the exact partition for boot, one space between part and number

--label "EFISTUB" #can be anything, it will appear in the boot entry list, keep it short and one word or even a single letter, must be contained by quotes and one space between --label and name

--loader #points to the location of the vmlinuz/kernel, for NixOS, it's the bzImage.efi inside /EFI/nixos/somenumber-bzimage.efi and this corresponds to the kernel in use (if multiple, you will know which one is in use from cat /proc/cmdline output) and note per EFI standard for files pointed to ESP, it requires file path to be written in backwards slash instead, efibootmgr can interpret forward slash but it is fragile, also contained within single quotes ' '

--unicode #allows more parameters

--root=UUID=... #this points to the root partition, in this example sda2, from this point you can copy paste the output of cat /proc/cmdline however when constructing the efibootmgr --create command this section must be contained within single quotes, one after --unicode 'root=...... and after the last kernel command line parameter add the last single quote ' , also pay attention where rw is placed, it should be either after root=UUID=423423....23423 rw or after initrd=\EFI\nixos\somenumber-initrd.efi rw

init=/.... #this is crucial for this distro to create the EFIstub, path should be written normally with forward slash and the value itself can be copied from cat /proc/cmdline output, init section, not to be confused with initrd.efi from /boot/EFI/nixos/somenumber-initrd.efi

--initrd=\EFI\nixos\... #this points to the initrd.efi in use shown from cat /proc/cmdline output, again path here should use backwards slash as it is inside the esp folder

loglevel=0 #these are the kernel command line parameters leave it as copied from cat /proc/cmdline output or modify them if you know what you are doing, do not forget to add the last single ' after the last parameter, no space in between the last word and the final quote.

After you have constructed the command in text file and added your particular system information, copy and paste the final command inside the terminal and press Enter. After password it should immediately show the new boot entry was created, pay attention to the number before the name such as Boot0000 EFISTUB, in the boot order (in this example) 0000 should be first. Also do not be worried if the EFI stub entry shows a lot of numbers, it is normal.

At this point you can reboot, though if it does not work, remember I have given disclaimers and warning to prepare backups.

Troubleshooting

Command was created but system will not boot

- go into UEFI firmware and change boot order, systemd-boot which is standard now is likely listed as Linux Boot Manager, place it first in the boot priority list so you can boot normally, alternatively some motherboards have a boot device list which can be shown after pressing a specific key on your keyboard to select the boot device, from that list select Linux Boot Manager if EFISTUB failed

- remove failed or old EFISTUB entry with efibootmgr commad, using above example where the efi stub is listed as 0000, to find out for your system use command

sudo efibootmgr

That will simply show the list of entries, assuming efistub is 0000 remove with command

sudo efibootmgr -b0000 -B

- reorder the boot entries, assuming EFISTUB is 0000 and Linux Boot Manager is 0001 and Boot order 0000,0001 and you want systemd-boot to be first again, use

sudo efibootmgr -o 0001,0000

Note it's lower case -o from order and do not use upper case -O as it will delete the boot order nor 0 (zero), if you use -O by mistake use sudo efibootmgr to get the entry list and sudo efibootmgr -o 0001,0000 to remake the boot order.

Other considerations, as you change the configuration and use other kernels which will get the corresponding bzImage inside /boot/EFI/nixos and make new nixos-rebuild switch generations which will get new initrd added to the folder you might lose track of what you used in the past, for what you need in the present consult cat /proc/cmdline output, if you want it to be more sorted make EFIstub folder inside /boot/EFI and copy bzImage and corresponding initrd files there and point efibootmgr to them when using the command. To get the current in use kernel and initrd you can also open the latest generation systemd-boot entry to overview inside /boot/loader/entries and note it requires using sudo -i first to access and open the latest entry with nano.

Also, sytemd-boot timeout can be removed and thus hide boot menu with

sudo -i

nano /boot/loader/loader.conf

Then change timeout 5 or whatever it is to 0 and Ctrl and x, y and Enter. Note this will hide the boot menu, to reveal again modify this parameter. The systemd boot menu can also be revealed, even if timeout is 0, by pressing and holding Esc key after pressing the power button, assuming that's not also the button used to enter UEFI, in which case try space bar or other keys, the important part is to press and hold before the bootloader step in the boot prcess, some laptops do very fast POST and firmware initialization, try again if the menu does not appear after restarting.

After modifying the timeout to 0, systemd-analyze output for loader using systemd-boot is arround 300ms or 0.3s depending on the hardware, kernel and kernel command line parameters, some might consider this already good enough and not worth using EFIstub, if you do use it, keep systemd-boot as a backup.

u/activedusk — 3 days ago
▲ 0 r/NixOS

Considering switching to NixOS, I have questions regarding casual PC use cases and GUI tools, if any

Hello,

I have fully switched to Linux about a year ago but I first tried Ubuntu about a decade and a half ago, but I mostly stuck to Windows in its XP, 7 and 10 variants until I decided it was time to use Linux exclusively for various reasons, TPM 2, legalized spyware pretending to be OS components, geopolitics, etc.

Since switching to Linux I have tried various implementations from Arch and Debian base, the latest being Linux Mint, however due to Debian being Debian, decided to search for alternatives and NixOS fits my list of demands, if am quite confused about their graphical implementations.

Long story short, is there:

- a GUI tool for changing kernels?

- a GUI tool for changing nvidia proprietary drivers?

- a GUI app store for installing and uninstalling packages?

- a GUI tool for updating packages and conversely changing update settings (how is the update cycle, rolling or LTS based?)

- a GUI tool to handle images (delete, switch to or create new) saved before the update?

Is everything meant to work as a config only? I'm sure I would not be the first to say this but the path to mass adoption requires the above, after hearing rumors that the government of France is potentially choosing NixOS as the base for their national OS I thought the state of the graphical tools/settings pages would be more...sorted.

reddit.com
u/activedusk — 6 days ago