REFInd: Difference between revisions

From NixOS Wiki
imported>Samueldr
m Re-words with proper tense; we can remove the note nearer to september IMHO
m Remove unneeded and problematic change
 
(8 intermediate revisions by 4 users not shown)
Line 23: Line 23:
rEFInd can be installed either using the derivation built using <tt>nix</tt> or by [https://www.rodsbooks.com/refind/getting.html downloading a pre-built binary]. rEFInd can then be placed at the default bootloader location (or anywhere else and then configured) in the ESP.
rEFInd can be installed either using the derivation built using <tt>nix</tt> or by [https://www.rodsbooks.com/refind/getting.html downloading a pre-built binary]. rEFInd can then be placed at the default bootloader location (or anywhere else and then configured) in the ESP.


The default boot location is <tt>/EFI/BOOT/BOOTX64.EFI</tt> on the ESP for x64_64.
The default boot location is:


{{note|This requires <tt><nixpkgs></tt> 18.03 or newer, previously rEFInd was marked as broken.}}
* <code>/EFI/BOOT/BOOTX64.EFI</code> on the ESP for <tt>x64_64</tt>
* <code>/EFI/BOOT/BOOTAA64.EFI</code> on the ESP for <tt>AArch64</tt>


=== Text-mode Only ===
Assuming the ESP is mounted at <tt>/boot/</tt>, a minimal installation (text-mode) without configuration can be made using nix this way (this will replace your default bootloader):
Assuming the ESP is mounted at <tt>/boot/</tt>, a minimal installation (text-mode) without configuration can be made using nix this way (this will replace your default bootloader):


<syntaxhighlight>
<syntaxhighlight lang=console>
sudo mkdir -p /boot/EFI/boot/
$ sudo mkdir -p /boot/EFI/boot/
sudo cp "$(nix-build --no-out-link -A 'refind')/share/refind/refind_x64.efi" /boot/EFI/boot/bootx64.efi
$ sudo cp "$(nix-build '<nixpkgs>' --no-out-link -A 'refind')/share/refind/refind_x64.efi" /boot/EFI/boot/bootx64.efi
</syntaxhighlight>
 
=== Graphical ===
If you have a fairly standard install and would like a full graphical installation with icons and buttons, the below will install refind to its own folder within your ESP:
<syntaxhighlight lang=console>
$ sudo nix-shell -p refind efibootmgr
$ refind-install
</syntaxhighlight>
</syntaxhighlight>


Line 38: Line 47:
A minimal hands-off configuration which allows some time to select an option follows:
A minimal hands-off configuration which allows some time to select an option follows:


<syntaxhighlight>
<syntaxhighlight lang=bash>
# Wait 2 seconds.
# Wait 2 seconds.
timeout 2
timeout 2
Line 50: Line 59:
The <tt>drivers_x64</tt> folder can also be copied next to the rEFInd EFI binary to allow it to handle filesystems not handled by your EFI implementations (though this is untested).
The <tt>drivers_x64</tt> folder can also be copied next to the rEFInd EFI binary to allow it to handle filesystems not handled by your EFI implementations (though this is untested).


<syntaxhighlight>
<syntaxhighlight lang="console">
~/nixpkgs $ ls -l $(nix-build --no-out-link -A 'refind')/share/refind/drivers_x64
$ ls -l $(nix-build '<nixpkgs>' --no-out-link -A 'refind')/share/refind/drivers_x64
total 528
total 528
-r--r--r-- 2 root root 89388 Dec 31  1969 btrfs_x64.efi
-r--r--r-- 2 root root 89388 Dec 31  1969 btrfs_x64.efi

Latest revision as of 17:37, 11 June 2024

rEFInd is a graphical boot manager for EFI- and UEFI-based computers, such as all Intel-based Macs and recent (most 2011 and later) PCs. rEFInd presents a boot menu showing all the EFI boot loaders on the EFI-accessible partitions, and optionally BIOS-bootable partitions on Macs. EFI-compatbile OSes, including Linux, provide boot loaders that rEFInd can detect and launch. rEFInd can launch Linux EFI boot loaders such as ELILO, GRUB Legacy, GRUB 2, and 3.3.0 and later kernels with EFI stub support. EFI filesystem drivers for ext2/3/4fs, ReiserFS, HFS+, and ISO-9660 enable rEFInd to read boot loaders from these filesystems, too. rEFInd's ability to detect boot loaders at runtime makes it very easy to use, particularly when paired with Linux kernels that provide EFI stub support.

<nixpkgs/pkgs/tools/bootloaders/refind/default.nix>

rEFInd cannot be used as-is to boot NixOS; there is no plumbing in NixOS allowing it to know about the generations. It can, though, be used as an intermediary, or secondary, bootloader to allow either selecting un-detected boot options or to help with recalcitrant UEFI implementations. Using it this way, NixOS is configured to setup any of its EFI bootloader as usual (grub, systemd-boot) and rEFInd should be able to detect those bootloaders in its default configuration.

Installation

rEFInd can be installed either using the derivation built using nix or by downloading a pre-built binary. rEFInd can then be placed at the default bootloader location (or anywhere else and then configured) in the ESP.

The default boot location is:

  • /EFI/BOOT/BOOTX64.EFI on the ESP for x64_64
  • /EFI/BOOT/BOOTAA64.EFI on the ESP for AArch64

Text-mode Only

Assuming the ESP is mounted at /boot/, a minimal installation (text-mode) without configuration can be made using nix this way (this will replace your default bootloader):

$ sudo mkdir -p /boot/EFI/boot/
$ sudo cp "$(nix-build '<nixpkgs>' --no-out-link -A 'refind')/share/refind/refind_x64.efi" /boot/EFI/boot/bootx64.efi

Graphical

If you have a fairly standard install and would like a full graphical installation with icons and buttons, the below will install refind to its own folder within your ESP:

$ sudo nix-shell -p refind efibootmgr
$ refind-install

Configuration

A minimal hands-off configuration which allows some time to select an option follows:

# Wait 2 seconds.
timeout 2
# Hide some stuff from the UI.
hideui banner
hideui hints

rEFInd will, by default, remember the last booted option.

The drivers_x64 folder can also be copied next to the rEFInd EFI binary to allow it to handle filesystems not handled by your EFI implementations (though this is untested).

$ ls -l $(nix-build '<nixpkgs>' --no-out-link -A 'refind')/share/refind/drivers_x64
total 528
-r--r--r-- 2 root root 89388 Dec 31  1969 btrfs_x64.efi
-r--r--r-- 2 root root 69894 Dec 31  1969 ext2_x64.efi
-r--r--r-- 2 root root 70918 Dec 31  1969 ext4_x64.efi
-r--r--r-- 2 root root 73688 Dec 31  1969 hfs_x64.efi
-r--r--r-- 2 root root 69930 Dec 31  1969 iso9660_x64.efi
-r--r--r-- 2 root root 79587 Dec 31  1969 ntfs_x64.efi
-r--r--r-- 2 root root 73712 Dec 31  1969 reiserfs_x64.efi

It may even be possible to use zfs when using the proper drivers.

External resources