Bootloader: Difference between revisions

From NixOS Wiki
imported>Samueldr
m Moves a generic FAQ entry from GRUB to here.
imported>Samueldr
m Ugh, wikimarkup != markdown
Line 18: Line 18:
=== Re-installing the bootloader ===
=== Re-installing the bootloader ===


* Something happened, and the bootloader doesn't work as expected.  
* Something happened, and the bootloader doesn't work as expected.  
* The ESP was re-made and nothing was kept
* The ESP was re-made and nothing was kept
* The ESP wasn't mounted and I want to re-generate the menu entries
* 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 <code>/mnt</code>. Next, run the [https://github.com/NixOS/nixpkgs/blob/e140d71d6330786c40b4bd9c0d59af7ad1a5e86a/nixos/modules/installer/tools/nixos-install.sh#L191-L192 command that the installer would run]. This will re-install the bootloader.
Booting from the installation media, mount the root partition, and the boot partition under <code>/mnt</code>. Next, run the [https://github.com/NixOS/nixpkgs/blob/e140d71d6330786c40b4bd9c0d59af7ad1a5e86a/nixos/modules/installer/tools/nixos-install.sh#L191-L192 command that the installer would run]. This will re-install the bootloader.

Revision as of 15:31, 3 February 2018

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.