Bootloader: Difference between revisions

imported>Lassulus
remove deprecated warning
imported>Scvalex
Mention nixos-enter as the easier way of entering an installed system from installation media, and expand the tips.
Line 78: Line 78:
==== From an installation media ====
==== From an installation media ====


Booting from the installation media, mount the root partition, and the boot partition under <code>/mnt</code>. Next, bind system virtual file systems under <code>/mnt</code>. Finally, 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 under <code>/mnt</code> and the boot partition under <code>/mnt/boot</code>. Next, enter the installed system with <code>nixos-enter</code>, or by manually binding the virtual filesystems and then calling <code>chroot</code>. Finally, 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.


<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
mount /dev/[root partition] /mnt
mount /dev/[root partition] /mnt
mount /dev/[boot partition] /mnt/boot
</syntaxhighlight>
</syntaxhighlight>
With <code>nixos-enter</code>:
<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
mount /dev/[boot partition] /mnt/boot
nixos-enter
NIXOS_INSTALL_BOOTLOADER=1 /nix/var/nix/profiles/system/bin/switch-to-configuration boot
</syntaxhighlight>
</syntaxhighlight>


Create a file called foo.sh and paste these lines into it:
Or manually:


<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
Line 95: Line 100:
</syntaxhighlight>
</syntaxhighlight>


Make it executable with chmod and then run it.
Tip: Be patient, it may take some times to re-install the bootloader for you.


Tip: Be patient, it may take some times to re-install the bootloader for you.
Tip: If the installation command fails with "<code>systemd-boot not installed in ESP</code>", try running <code>bootctl install</code>.
 
Tip: If you've replaced your drives, or have otherwise re-created the <code>/mnt/boot</code> partition, you may want to keep using the same UUID for it.  You can use <code>mlabel</code> from the <code>mtools</code> package for this.


=== New generations are not in the boot menu ===
=== New generations are not in the boot menu ===