# rEFInd

Related articles

- Arch boot process
- Boot loaders
- Unified Extensible Firmware Interface

rEFInd is a UEFI boot manager. It is a fork of the no-longer-maintained rEFIt and fixes many issues with respect to non-Mac UEFI booting. It is designed to be platform-neutral and to simplify booting multiple OSes.

## Installation

Install refind-efi from the Official repositories. Then run

    # refind-install

This should detect your kernel and EFI system partition, copy any necessary files to the ESP, create default configuration files, and set rEFInd as the default UEFI boot entry.

## Manual Installation

Tip: rEFInd can boot Linux in many ways. See The rEFInd Boot Manager: Methods of Booting Linux for coverage of the various approaches. This section illustrates the process when using EFISTUB.
Note: For 32-bit EFI, replace x64 with ia32 in the commands below.

If the `refind-install` script does not work for you, rEFInd can be set up manually.

1. Create a directory in the ESP to store rEFInd's files. Here we assume your ESP is mounted to `/boot/efi` and you are storing rEFInd in `/boot/efi/EFI/refind`.
2. Copy the executable, config, and resource files to the ESP

       # cp /usr/share/refind/refind_x64.efi /boot/efi/EFI/refind/refind_x64.efi
       # cp /usr/share/refind/refind.conf-sample /boot/efi/EFI/refind/refind.conf
       # cp -r /usr/share/refind/{icons,fonts,drivers_x64} /boot/efi/EFI/refind/

3. Edit the config file you just copied. The file is well commented and self-explanatory. By default, rEFInd will scan your drives for EFISTUB kernels so you may not need to make any changes in order to boot.
4. If you need to customize kernel boot options, copy the example config file to the directory of your kernel. Edit the file to use the correct `PARTUUID` and `rootfstype` for your root partition (use `blkid` and `lsblk -f`).

       # cp /usr/share/refind/refind_linux.conf-sample /boot/refind_linux.conf

   Tip: Each line of `refind_linux.conf` is displayed as a submenu by rEFInd. Access the submenu with +, Insert, or F2.
5. Use `efibootmgr` to create a boot entry in the UEFI NVRAM (change X and Y to match the device and partition of your ESP). See the man page for `efibootmgr` for more info.

       # efibootmgr -c -d /dev/sdX -p Y -l /EFI/refind/refind_x64.efi -L "rEFInd"

Tip: Pressing F10 in the rEFInd menu will save a screenshot to the top level directory of the ESP.

### Custom Menu Entries

If you want more control over the options for a menu entry, you can manually create boot entries using stanzas in `refind.conf`. Ensure that `scanfor` includes `manual` or these entries won't appear in rEFInd's menu.

    refind.conf

    menuentry "Arch Linux" {
            icon     /EFI/refind/icons/os_arch.icns
            volume   1:
            loader   /boot/vmlinuz-linux
            initrd   /boot/initramfs-linux.img
            options  "root=PARTUUID=3518bb68-d01e-45c9-b973-0b5d918aae96 rw rootfstype=ext4"
    }

## Using rEFInd with an existing UEFI Windows installation

Note: The usual caveats of Windows and Arch Dual Boot apply.

rEFInd is compatible with the EFI system partition created by a UEFI Windows installation, so there is no need to create or format another FAT32 partition when installing Arch alongside Windows. Simply mount Windows' ESP and install rEFInd as usual. By default, rEFInd's autodetection feature should recognize any existing Windows/recovery bootloaders.

## Upgrading rEFInd

Pacman updates the rEFInd files in `/usr/share/refind` and will not copy new files to the ESP for you. If `refind-install` worked for your original installation of rEFInd, you can rerun it to copy the updated files. The new config file will be copied as `refind.conf-sample` so - like a `.pacdiff` file - you can choose which changes to incorporate into your config file.

Otherwise you can copy the new files manually as above.

### Systemd Automation

To automate the process of copying refind files and updating the nvram (if needed) use the following script.

Note: If you want to change the directory that refind is installed in the UEFISYS partition, just change the value of $refind_dir in the script

    /usr/lib/systemd/scripts/refind_name_patchv2

    #!/usr/bin/env bash
    ## COPYRIGHT 2013 : MARK E. LEE (BLUERIDER) : mlee24@binghamton.edu; mark@markelee.com

    ## LOG
    ## 1/17/2013 : Version 2 of refind_name_patch is released
    ##           : Supports long subdirectory location for refind
    ##           : Updates nvram when needed
    ##           : 10% speed boost
    ## 7/15/2013 : Changed arch to match 32-bit (ia32) and 64-bit (x64) naming scheme
    ##           : Changed directory copying in update-efi-dir to copy tools and drivers directories explicitly
    ##           : Changed efibootmgr writing code to be more concise and added (-w) to write the entry as per dusktreader's excellent guide : https://docs.google.com/document/d/1pvgm3BprpXoadsQi38FxqMOCUZhcSqFhZ26FZBkmn9I/edit
    ##           : Function to check if NVRAM boot entry was already listed was fixed to use awk and an if then clause
    ##           : ref_bin_escape was modified from : ref_bin_escape=${ref_bin//\//\\\\} to remove extra backslashes (error does not show up when using cmdline)
    ## 7/29/2013 : Changed location of tools,drivers, and binary directory to match capricious upstream move to /usr/share/refind

    function main () {  ## main insertion function
      declare -r refind_dir="/boot/efi/EFI/refind"; ## set the refind directory
      arch=$(uname -m | awk -F'_' '{if ($1 == "x86") {print "x"$2} else if ($1 == "i686") {print "ia32"}}') &&  ## get bit architecture
      update-efi-dir;  ## updates or creates the refind directory
      update-efi-nvram;  ## updates nvram if needed
    }

    function update-efi-dir () {  ## setup the refind directory
      if [ ! -d $refind_dir ]; then  ## check if refind directory exists
        echo "Couldn't find $refind_dir";
        mkdir $refind_dir &&  ## make the refind directory if needed
        echo "Made $refind_dir";
      fi;
      if [ "$arch" ]; then  ## check if anything was stored in $arch
        cp -r /usr/share/refind/{refind_$arch.efi,keys,images,icons,fonts,docs,{tools,drivers}_$arch} $refind_dir/  && ## update the bins and dirs
        echo "Updated binaries and directory files for refind at $refind_dir";
       else
        echo "Failed to detect an x86 architecture";
        exit;
      fi;
    }

    function update-efi-nvram () { ## update the nvram with efibootmgr
      declare -r ref_bin=${refind_dir/\/boot\/efi}/refind_$arch.efi;  ## get path of refind binary (without /boot/efi)
      declare -r ref_bin_escape=${ref_bin//\//\\};  ## insert escape characters into $ref_bin
      [ "$(efibootmgr -v | awk "/${ref_bin_escape//\\/\\\\}/")" ] && ( ## check if boot entry is in nvram \
        echo "Found boot entry, no need to update nvram";
        ) || ( ## if boot entry is not in nvram; add it
        declare -r esp=$(mount -l | awk '/ESP/ {print $1}') &&  ## get ESP partition
        efibootmgr -cgw -d ${esp:0:8} -p ${esp:8} -L "rEFInd" -l $ref_bin_escape && ## update nvram
        echo "
        Updated nvram with entry rEFInd to boot $ref_bin
        Did not copy configuration files, please move refind.conf to $refind_dir/";
        )
    }
    main;  ## run the main insertion function

    /usr/lib/systemd/system/refind_update.path

    [Unit]
    Description=Update rEFInd bootloader files

    [Path]
    PathChanged=/usr/share/refind/refind_<arch>.efi
    Unit=refind_update.service

    [Install]
    WantedBy=multi-user.target

    /usr/lib/systemd/system/refind_update.service

    [Unit]
    Description=Update rEFInd directories, binaries, and nvram

    [Service]
    Type=oneshot
    ExecStart=/usr/bin/bash /usr/lib/systemd/scripts/refind_name_patchv2
    RemainAfterExit=no

Enable the systemd path unit by running:

    # systemctl enable refind_update.path

## Apple Macs

mactel-boot from the AUR is an experimental "bless" utility for Linux. If that does not work, use "bless" from within OSX to set rEFInd as the default boot entry. Assuming your UEFISYS partition is mounted at `/mnt/efi` within OSX, do

    $ sudo bless --setBoot --folder /mnt/efi/EFI/refind --file /mnt/efi/EFI/refind/refind_x64.efi

## VirtualBox

See VirtualBox#Using Arch under Virtualbox EFI mode.

## See also

- The rEFInd Boot Manager by Roderick W. Smith.

Category:

- Boot loaders