rEFInd

提供: ArchWiki
2014年4月8日 (火) 15:03時点におけるKusakata (トーク | 投稿記録)による版
(差分) ← 古い版 | 最新版 (差分) | 新しい版 → (差分)
ナビゲーションに移動 検索に移動

rEFInd は UEFI のブートマネージャです。既にメンテナンスされてない rEFIt のフォークであり、Mac 以外の UEFI ブートに関して多数の問題が修正されています。プラットフォームに依存せず、複数の OS を簡単に起動できるように設計されています。

インストール

公式リポジトリから refind-efi をインストールしてください。そして次のコマンドを実行します:

# refind-install

これでカーネルと EFI システムパーティションが検出されて、必要なファイルが ESP にコピーされ、デフォルトの設定ファイルが作成され、rEFInd がデフォルトの UEFI ブートエントリに設定されるはずです。

手動設定

ヒント: rEFInd は様々な方法で Linux を起動することができます。The rEFInd Boot Manager: Methods of Booting Linux でそれらの方法が触れられています。このセクションでは EFISTUB を使用する場合の方法を説明しています。
ノート: 32ビットの IA32 EFI を使っている場合、下のコマンドにある x64ia32 に置き換えてください。

refind-install スクリプトが上手く動かない場合、rEFInd を手動で設定することができます。

  1. ESP にディレクトリを作成して rEFInd のファイルを保存してください。ここでは ESP が /boot/efi にマウントされており rEFInd を /boot/efi/EFI/refind に保存することにします。
  2. 実行ファイル、設定、リソースファイルを 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. コピーした設定ファイルを編集して下さい。このファイルには注釈が沢山つけられています。デフォルトので、rEFInd はドライブをスキャンして EFISTUB カーネルを探すので、起動するのに変更を加える必要はありません。
  4. カーネルブートオプションをカスタマイズする必要がある場合、サンプル設定ファイルをカーネルのディレクトリにコピーしてください。ファイルを編集して root パーティションに適切な PARTUUIDrootfstype を使って下さい (blkidlsblk -f を使用します)。
    # cp /usr/share/refind/refind_linux.conf-sample /boot/refind_linux.conf
    
    ヒント: refind_linux.conf のそれぞれの行は rEFInd によってサブメニューとして表示されます。サブメニューは "+", "Insert", "F2" キーで開けます。
  5. efibootmgr を使って UEFI NVRAM に ESP のデバイスとパーティションでブートエントリを作成してください:
    # efibootmgr -c -d /dev/sdX -p Y -l /EFI/refind/refind_x64.efi -L "rEFInd"
    
ヒント: rEFInd のメニューで F10 を押すと ESP の一番上のディレクトリにスクリーンショットが保存されます。

カスタムメニューエントリ

オプションを使ってメニューエントリを細かく操作したい場合、手動で refind.conf にブートエントリを作成することができます。scanfor には manual を含めて下さい、そうしないとエントリが rEFInd のメニューに表示されません。

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"
}

既存の UEFI Windows 環境で rEFInd を使う

ノート: 基本的には Windows and Arch Dual Boot に書かれていることが適用されます。

rEFInd は UEFI の Windows をインストールしたときに作成される EFI システムパーティションに対応しているため、Windows と一緒に Arch をインストールする際にもうひとつ FAT32 パーティションを作成・フォーマットする必要はありません。Windows の ESP をマウントして通常通りに rEFInd をインストールするだけです。デフォルトで、rEFInd の自動検出機能が既存の Windows (リカバリ) ブートローダーを認識するはずです。

rEFInd を更新する

refind パッケージの新しいバージョンを pacman でアップデートとしてインストールした場合、上のセクションにあるような refind.conf や refind_linux.conf を除いて、refind のディレクトリとファイルをコピーする必要があります。

rEFInd を自動で最新バージョンに更新するために、(cronjob で) refind-install を実行することができます。もしくは下で記述しているように systemd のスクリプトを使います。 以下のようにコマンドは実行されます:

/usr/bin/refind-install
Installing rEFInd on Linux....
ESP was found at /boot/efi using vfat
Found rEFInd installation in /boot/efi/EFI/refind; upgrading it.
Installing driver for ext4 (ext4_x64.efi)
Copied rEFInd binary files

Notice: Backed up existing icons directory as icons-backup.
Existing refind.conf file found; copying sample file as refind.conf-sample
to avoid overwriting your customizations.

rEFInd has been set as the default boot manager.
Existing //boot/refind_linux.conf found; not overwriting.

Installation has completed successfully.

Systemd による自動化

以下のスクリプトを使うことで、refind ファイルのコピーと (必要ならば) nvram の更新を自動化することができます。

ノート: UEFISYS パーティションで refind をインストールするディレクトリを変更したい場合は、スクリプトの中の $refind_dir の値を変更してください。
/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 Mac

AUR にある mactel-bootAUR は Linux 用の実験的な "bless" ユーティリティです。これが動作しないときは、OSX の中から "bless" を使って rEFInd をデフォルトのブートローダに設定してください。OSX の中で UEFISYS パーティションが /mnt/efi にマウントされている場合、次を実行します:

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

VirtualBox

VirtualBox#Virtualbox の EFI モードで Arch を使う を参照してください。

参照