REFInd: Difference between revisions

From Alpine Linux
(fixed typo)
m (Prabuanand moved page Refind to REFInd: to fix the name of page to align with the actual name)
(No difference)

Revision as of 05:42, 26 June 2025

rEFInd provides a graphical boot menu for UEFI systems, that allows to boot operating systems that are found on the available partitions.

Installation

As of now, refind is available in the testing repository. It can be safely installed by following the guidelines.

The below command installs the alpine-linux rEFInd package:

# apk add refind@testing

Configuration

rEFInd's refind-install script creates a sample file /boot/refind_linux.conf.

# refind-install

The above steps should be sufficient for most cases to start using rEFInd as boot loader. A sample /boot/refind_linux.conf from rEFInd website for a system with ext4 filesystem is given below:

Contents of /boot/refind_linux.conf

"Boot with standard options" "ro root=UUID=084f544a-7559-4d4b-938a-b920f59edc7e splash=silent quiet showopts " "Boot to single-user mode" "ro root=UUID=084f544a-7559-4d4b-938a-b920f59edc7e splash=silent quiet showopts single" "Boot with minimal options" "ro root=UUID=084f544a-7559-4d4b-938a-b920f59edc7e" # This line is a comment

This sample file defines three entries:

  • The first entry uses options derived from the contents of /proc/cmdline when the script was run, unless the script was run from an emergency system, in which case refind-install tries to translate from options in /etc/default/grub.
  • The second entry provides the same boot options as the first, but adds single, which causes most distributions to boot into a single-user maintenance mode.
  • The final entry subtracts most options from the list, leaving only ro root=rootfs, where rootfs is the identified root (/) filesystem. This option may not be bootable on some systems that need unusual options, but if it does boot, it will normally do so with verbose startup messages, which can be helpful when debugging boot problems.

Given below is a sample /boot/refind_linux.conf created automatically by rEFInd for a system with Btrfs filesystem whose layout is given further below as blkid output:

Contents of /boot/refind_linux.conf

"Boot with standard options" "root=LABEL=_SYS0_ modules=sd-mod,usb-storage,btrfs rootflags=subvol=@ resume=LABEL=_SWAP_ ro quiet" "Boot to single-user mode" "root=LABEL=_SYS0_ modules=sd-mod,usb-storage,btrfs rootflags=subvol=@ resume=LABEL=_SWAP_ ro quiet single" "Boot with minimal options" "ro root=UUID=aafbf6b0-7d54-4222-a3dd-a8f45c0ac607"

Output of blkid from Busybox is given below.

/dev/sda4: LABEL="_SWAP_" UUID="33899521-599f-458e-9bfe-f4b59254eb7c" TYPE="swap" 
/dev/sda3: LABEL="_SYS0_" UUID="aafbf6b0-7d54-4222-a3dd-a8f45c0ac607" TYPE="btrfs"
/dev/sda1: LABEL="_BOOT_" UUID="6771-DB5C" TYPE="vfat" 

The single-user mode and minimal options does not work in Alpine Linux for Btrfs filesystem as per user u/Xerotras in https://redd.it/1hbog74

Note: The refind utility currently does not have Alpine Linux icon file. You can place the icon file in /boot/efi/EFI/refind/icons/ or /boot/EFI/refind/icons/ folder.
Alpine linux icon file for refind
icon file

Proceed to Manual configuration only if rebooting did not result in rEFInd appearing as boot loader.

Manual configuration

And a first (default) boot menu line needs to be configured with Alpine's default boot parameters. Assuming the bootable partition is mounted at /media/sdXY it can be done like this (at time of writing):

# echo '"Alpine" "modules=loop,squashfs,sd-mod,usb-storage quiet initrd=\boot\intel-ucode.img initrd=\boot\amd-ucode.img initrd=\boot\initramfs-lts"' > /media/sdXY/boot/refind_linux.conf

Note: At the time of writing, it was still needed to use backslashes in the .conf file.
The path in the config file needs to be relative to the partition that the kernel resides on. If /boot resides on its own separate partition, then \boot needs to be removed from the paths.

There is also a second config file, refind.conf which is located inside the EFI partition. The config file is self-explanatory and has to be manually edited. Refer refind website for additional information.

The below instructions assume esp partition is mounted as shown:

Contents of /etc/fstab

... UUID=ABCD-1234 /boot/efi vfat rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=utf8,shortname=mixed,errors=remount-ro 0 2 ...

If your setup is different from above, adjust the path in below files accordingly.

For default alpine sys mode installation, a sample refind.conf to dual boot Alpine Linux and windows will be:

Contents of /boot/efi/EFI/refind/refind.conf

timeout 20 resolution 1920 1080 use_graphics_for windows,linux menuentry "Windows" { loader /EFI/Microsoft/Boot/bootmgfw.efi icon /EFI/refind/icons/os_win.png } menuentry "Alpine Linux" { icon /EFI/refind/icons/os_alpine.png volume ROOT loader /boot/vmlinuz-lts initrd /boot/initramfs-lts options "root=UUID=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx rw" }

If you use btrfs filesystem, for the above /etc/fstab setup, the necessary boot entry for Alpine Linux is as follows:

Contents of /boot/efi/EFI/refind/refind.conf

menuentry "Alpine Linux" { icon /EFI/refind/icons/os_alpine.png volume BTRFSVOL loader @alpine/boot/vmlinuz-lts initrd @alpine/boot/initramfs-lts options "root=UUID=823a3283-30a7-4fef-b50b-8a2230c71b5b rw rootflags=subvol=@alpine rootfstype=btrfs" # PARTUUID not working for alpine }
Tip: If the above configuration is working perfectly,there is no need for other bootloaders and they can be safely removed.

Troubleshooting

See also