Bootloader: Difference between revisions

imported>Scvalex
Mention nixos-enter as the easier way of entering an installed system from installation media, and expand the tips.
imported from old wiki
(7 intermediate revisions by 6 users not shown)
Line 1: Line 1:
{{expansion|Explain what the bootloader does and which bootloader exists. Also explain Legacy Boot vs. UEFI and bootloaders for ARM platforms (with links)}}
== FAQ ==
 
=== What is a bootloader? ===
 
A bootloader is a type of software that manages the loading of the operating system (OS) on the computer at startup. It is responsible for preparing the system before passing control to the OS. Here are the types of bootloaders commonly used in NixOS:
* '''GRUB (Grand Unified Bootloader)''': Widely used, supports multiple operating systems, and provides a boot menu to select how the system boots.
* '''systemd-boot''': Simple UEFI-only bootloader, formerly known as gummiboot.
* '''EFISTUB''': Utilizes the UEFI firmware itself to boot the kernel, without the need for a traditional bootloader.
 
=== Legacy Boot vs UEFI ===
 
Legacy Boot and UEFI are two different methods of starting a computer. Legacy Boot, also known as BIOS, uses the Master Boot Record (MBR) to start the system, while UEFI (Unified Extensible Firmware Interface) uses the GUID Partition Table (GPT) and is the modern standard. UEFI supports larger hard drives, faster boot times, and more security features compared to Legacy Boot. Additionally, UEFI provides a better user interface and a more robust pre-boot environment.
 
=== Bootloaders for ARM platforms ===
 
On ARM platforms, the bootloader options can vary significantly based on the architecture and specific hardware. Common bootloaders include:
* '''U-Boot''': Universal Boot Loader, widely used in ARM devices.
* '''EFI ARM bootloaders''': Some ARM devices support UEFI, allowing the use of standard UEFI bootloaders like GRUB or systemd-boot.


== FAQ ==
For more detailed information on NixOS and ARM architecture, refer to the [https://nixos.wiki/wiki/NixOS_on_ARM NixOS on ARM] docs.


=== Am I booted in Legacy or UEFI? ===
=== Am I booted in Legacy or UEFI? ===
Line 24: Line 41:
</syntaxhighlight>
</syntaxhighlight>


=== Limiting amount of entries with grub ===
=== Limiting amount of entries with grub or systemd-boot ===
 
The grub and systemd-boot modules has an option to limit the number of configurations made available in the boot partition, {{nixos:option|boot.loader.grub.configurationLimit}} or {{nixos:option|boot.loader.systemd-boot.configurationLimit}}. Setting this to a lower amount than the default may help reduce the occasions where too many different kernels and initrds are added to the <tt>/boot</tt> partition or <tt>ESP</tt>.
 
=== Why I still boot into systemd-boot after switching to grub in my configuration? ===


The grub module has an option to limit the number of configurations made available in the boot partition, {{nixos:option|boot.loader.grub.configurationLimit}}. Setting this to a lower amount than the default may help reduce the occasions where too many different kernels and initrds are added to the <tt>/boot</tt> partition or <tt>ESP</tt>.
Make sure to check if in your boot order, '''NixOS-bootloader''' is the default / first option.


=== Keeping kernels/initrd on the main partition ===
=== Keeping kernels/initrd on the main partition ===
Line 51: Line 72:
== Troubleshooting ==
== Troubleshooting ==


=== Re-installing the bootloader ===
=== Kernel initramfs parameters for troubleshooting boot issues ===
 
* Something happened, and the bootloader doesn't work as expected.
* The ESP was re-made and nothing was kept
* The ESP wasn't mounted and I want to re-generate the menu entries
 
==== From a running system ====
 
<syntaxhighlight lang="bash">
sudo nixos-rebuild --install-bootloader switch
</syntaxhighlight>


kernel command line options to help debugging (reached via e on the grub boot menu)
You can add these flags to systemd-boot and grub boot entries via using the <code>e</code> command to edit the currently selected entry, then use arrow keys to move curser and type your additions in the entry area.  Type return or <code>F10</code> (Grub) to boot the entry.


* <code>boot.trace</code> uses set -x to trace the shell scripts.
* <code>boot.trace</code> uses <code>set -x</code> to trace the shell scripts.
* <code>boot.shell_on_fail</code> allows for a shell if failure to boot.
* <code>boot.shell_on_fail</code> allows for root shell if failure to boot. ''Requires root password.''
* <code>boot.debug1</code> allows shell and stops right away on failure.
* <code>boot.debug1</code> allows shell and stops right away on failure.
* <code>boot.debug1devices</code> stop after loading modules and creating device nodes.
* <code>boot.debug1devices</code> stop after loading modules and creating device nodes.
* <code>boot.debug1mounts</code> stop after mounting file systems.
* <code>boot.debug1mounts</code> stop after mounting file systems.
* <code>boot.panic_on_fail</code> panics on failure.
* <code>boot.panic_on_fail</code> panics on failure.
* <code>console=</code> set the console to something
* <code>console=</code> set the console to something.
* <code>root=</code> If a root device is specified on the kernel command line, make it available through the symlink /dev/root.
* <code>root=</code> If a root device is specified on the kernel command line, make it available through the symlink /dev/root.
* <code>findiso=</code> if an iso name is supplied, try to find the device where the iso resides on.
* <code>findiso=</code> if an iso name is supplied, try to find the device where the iso resides on.
* <code>copytoram</code> Skip mounting the ISO and copy its content to a tmpfs.
* <code>copytoram</code> Skip mounting the ISO and copy its content to a tmpfs.
=== Re-installing the bootloader ===
* Something happened, and the bootloader doesn't work as expected.
* The ESP was re-made and nothing was kept.
* The ESP wasn't mounted and I want to re-generate the menu entries.
==== From a running system ====
<syntaxhighlight lang="bash">
sudo nixos-rebuild --install-bootloader boot
</syntaxhighlight>


==== From an installation media ====
==== From an installation media ====
Line 182: Line 205:


If you have some problems with installation, report them on [https://matrix.to/#/#nix:nixos.org #nix:nixos.org on Matrix].
If you have some problems with installation, report them on [https://matrix.to/#/#nix:nixos.org #nix:nixos.org on Matrix].
[[Category:Booting]]