rEFInd (简体中文)
rEFInd 是一个 UEFI 启动管理器。它是 rEFIt (不再维护)的一个分支并且针对非 Mac 硬件修复了若干问题。它被设计为平台无关,可启动多个操作系统。
Contents
安装
从官方软件源安装 refind-efi。然后运行
# refind-install
此操作会检测您的内核和 EFI system partition 分区,复制需要的文件,创建默认配置文件并将 rEFInd 设置为默认的 UEFI 启动项
手动安装
如果 refind-install
脚本没有正常工作,您可以手动设置 rEFInd。
- 在 ESP 中创建一个目录来存放 rEFInd 的文件。此处假定您的 ESP 分区被挂载到
/boot/efi
并且您希望将 rEFInd 存放在/boot/efi/EFI/refind
。 - 将可执行文件、配置文件和资源文件复制到 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/
- 编辑刚才复制的配置文件。该文件有详细的注释。默认情况下,rEFInd 会在您的驱动器中寻找 EFISTUB 内核,所以您可能不需要做任何更改就能启动。
- 如果需要定制内核引导选项,复制示例配置文件到你的内核的目录。编辑该文件并为您的根分区输入正确的
PARTUUID
和rootfstype
(可以使用blkid
和lsblk -f
).# cp /usr/share/refind/refind_linux.conf-sample /boot/refind_linux.conf
Tip:refind_linux.conf
的每一行都会被显示为一个子菜单项。按下 + 、 Insert 或 F2 来展开子菜单. - 使用
efibootmgr
创建一条 UEFI 启动项(更改 X 、Y 使其指向您的 ESP 分区)。 参见efibootmgr
的 man 手册.# efibootmgr -c -d /dev/sdX -p Y -l /EFI/refind/refind_x64.efi -L "rEFInd"
自定义菜单项
您可以使用 refind.conf
中的小节手动创建启动条目。 确保 scanfor
包括 manual
否则条目将不会出现。
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" }
在已有的 Windows UEFI 安装中使用 rEFIND
rEFInd 兼容 UEFI Windows 安装时创建的 EFI 系统分区,因此没有必要创建或格式化另一个 FAT32 分区。只需挂载 Windows 的 ESP 并像往常一样安装 rEFInd。默认情况下,rEFInd 的自动检测功能应该识别任何现有的 Windows 引导程序。
更新 rEFInd
Pacman 只更新在 /usr/share/refind
中的文件,不会将新文件复制到 ESP。
如果 refind-install
成功安装了 rEFInd,则可以再次运行以更新文件。 新的配置文件会被复制为 refind.conf-sample
——就像 .pacdiff
—— 你可以选择改变合并到你的配置文件。
否则,您可以重复上文的步骤,复制新的文件。
Systemd 自动化
如果需要自动复制 rEFInd 文件和更新 NVRAM(如果需要),可以使用下面的脚本。
/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
运行以下命令以激活这个 systemd path 单元:
# systemctl enable refind_update.path
Apple Macs
AUR 上的 mactel-bootAUR 是 "bless" 工具的实验性替代品。如果它不能正常工作,
在 OS X 中使用 "bless" 来将 rEFInd 设置为默认启动项。假设您的 UEFISYS 分区挂载到 /mnt/efi
。
$ sudo bless --setBoot --folder /mnt/efi/EFI/refind --file /mnt/efi/EFI/refind/refind_x64.efi
VirtualBox
参见 VirtualBox#Using Arch under Virtualbox EFI mode[broken link: invalid section].
参见
- The rEFInd Boot Manager by Roderick W. Smith.