Bootloader

From NixOS Wiki
Revision as of 15:29, 3 February 2018 by imported>Samueldr (Moves a generic FAQ entry from GRUB to here.)

FAQ

How do I remove older generations from the bootloader?

First, collect garbages in your system, then rebuild. The scripts will collect leftover files.

The first command, in the example below, removes everything older than 14 days.

sudo nix-collect-garbage --delete-older-than 14d 
sudo nixos-rebuild boot

Troubleshooting

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

Booting from the installation media, mount the root partition, and the boot partition under /mnt. Next, run the command that the installer would run. This will re-install the bootloader.

mount /dev/[root partition] /mnt
mount /dev/[boot partition] /mnt/boot
NIXOS_INSTALL_BOOTLOADER=1 chroot /mnt \
    /nix/var/nix/profiles/system/bin/switch-to-configuration boot

New generations are not in the boot menu

The most common cause for this situation is when the ESP isn't mounted where NixOS expects it to be on UEFI systems. NixOS assumes the ESP is mounted under /boot and that it is on the ESP that NixOS will install the files needed for the boot process for UEFI systems.[1] This issue should affect all supported UEFI bootloaders equally for NixOS.

The usual fix for this problem is to add the missing entry for fileSystems."/boot" in hardware-configuration.nix (or where your mount points are defined). Follow the steps in #Re-installing the bootloader to re-generate the menu entries, then boot in your system to add the missing configuration. The next generations should work as expected in your bootloader.