「Unified カーネルイメージ」の版間の差分

提供: ArchWiki
ナビゲーションに移動 検索に移動
(一部翻訳)
15行目: 15行目:
 
{{Note|記事全体で {{ic|''esp''}} は [[EFI システムパーティション]] のマウントポイントを表します。}}
 
{{Note|記事全体で {{ic|''esp''}} は [[EFI システムパーティション]] のマウントポイントを表します。}}
   
== Preparing a unified kernel image ==
+
== unified カーネルイメージの準備 ==
   
 
=== mkinitpcio ===
 
=== mkinitpcio ===
   
  +
例として実行することで機能をテストできます
One can test the feature by running as an example
 
   
 
# mkinitcpio -p linux -- --uefi ''esp''/EFI/Linux/test-systemd.efi
 
# mkinitcpio -p linux -- --uefi ''esp''/EFI/Linux/test-systemd.efi
   
  +
これにより、''linux'' プリセットのカーネルイメージが生成されます。
This would produce a kernel image for the ''linux'' preset.
 
   
==== .preset file ====
+
==== .preset ファイル ====
   
  +
まず、[[EFI システムパーティション]] の適切なマウントポイントを指定して、 {{ic|/etc/mkinitcpio.d/linux.preset}} あるいは使用しているプリセットを以下のように変更します。
First, modify {{ic|/etc/mkinitcpio.d/linux.preset}}, or the preset that you are using, as follows, with the appropriate mount point of the [[EFI system partition]] :
 
   
* If your system requires [[Microcode]], add {{ic|1=ALL_microcode=(/boot/*-ucode.img)}} to tell [[mkinitcpio]] where to find it.
+
* [[マイクロコード]] が必要な場合は、{{ic|1=ALL_microcode=(/boot/*-ucode.img)}} を追加して、[[mkinitcpio]] にその場所を追加します。
* Add a {{ic|1=''PRESET''_efi_image=}} parameter for each item in {{ic|1=PRESETS=}}, i.e. {{ic|1=default_efi_image="''esp''/EFI/Linux/archlinux-linux.efi"}} and {{ic|1=fallback_efi_image="''esp''/EFI/Linux/archlinux-linux-fallback.efi"}}. This sets the executable filename.
+
* {{ic|1=''PRESET''_efi_image=}} {{ic|1=PRESETS=}} の各項目に対して、{{ic|1=''PRESET''_efi_image=}} パラメータを追加します。{{ic|1=default_efi_image="''esp''/EFI/Linux/archlinux-linux.efi"}} {{ic|1=fallback_efi_image="''esp''/EFI/Linux/archlinux-linux-fallback.efi"}} の各項目です。これにより、実行ファイル名が設定されます。
* Optionally, append {{ic|--splash /usr/share/systemd/bootctl/splash-arch.bmp}} to each {{ic|1=''PRESET''_options=}} line to add a splash image, i.e. {{ic|1=default_options="--splash /usr/share/systemd/bootctl/splash-arch.bmp"}} and {{ic|1=fallback_options="-S autodetect --splash /usr/share/systemd/bootctl/splash-arch.bmp"}}.
+
* オプションとして、各 {{ic|--splash /usr/share/systemd/bootctl/splash-arch.bmp}} 行に {{ic|1=''PRESET''_options=}} を追加して、スプラッシュ画像を追加することも可能です、つまり {{ic|1=default_options="--splash /usr/share/systemd/bootctl/splash-arch.bmp"}} {{ic|1=fallback_options="-S autodetect --splash /usr/share/systemd/bootctl/splash-arch.bmp"}} のように指定します。
   
  +
以下は、{{Pkg|linux}} カーネルと Arch のスプラッシュスクリーンのための {{ic|linux.preset}} の動作例です。
Here is a working example {{ic|linux.preset}} for the {{Pkg|linux}} kernel and the Arch splash screen.
 
   
 
{{hc|/etc/mkinitcpio.d/linux.preset|2=
 
{{hc|/etc/mkinitcpio.d/linux.preset|2=
53行目: 53行目:
 
}}
 
}}
   
  +
この2番目の例では、{{Pkg|linux}} のデフォルトイメージと {{Pkg|linux-lts}} のフォールバックイメージを作成します。
This second example builds a default image for {{Pkg|linux}} and a fallback image for {{Pkg|linux-lts}} :
 
   
 
{{hc|/etc/mkinitcpio.d/linux.preset|2=
 
{{hc|/etc/mkinitcpio.d/linux.preset|2=
72行目: 72行目:
 
}}
 
}}
   
{{Tip|If you are using multiple kernels, make sure your [[ESP]] has enough space, as [[mkinitcpio]] currently builds both the {{ic|initramfs-*.img}} and the {{ic|*.efi}} executable, thereby doubling the space used. See [https://github.com/archlinux/mkinitcpio/issues/77]}}
+
{{Tip|複数のカーネルを使用している場合は、[[ESP]] に十分なスペースがあることを確認してください。[[mkinitcpio]] は現在 {{ic|initramfs-*img}}{{ic|*.efi}}実行可能ファイル。これにより、使用されるスペースが2倍になります。 [https://github.com/archlinux/mkinitcpio/issues/77] を参照してください。}}
   
==== Kernel command line ====
+
==== カーネルコマンドライン ====
   
Next, create {{ic|/etc/kernel/cmdline}} with your [[kernel parameters]].
+
次に、[[カーネルパラメータ]] を使用して {{ic|/etc/kernel/cmdline}} を作成します。
   
 
# cp /proc/cmdline /etc/kernel/cmdline
 
# cp /proc/cmdline /etc/kernel/cmdline
   
{{Warning| {{ic|initrd}} entries pointing at microcode and the initramfs need to be removed.}}
+
{{Warning|{{ic|initrd}} マイクロコードと initramfs を指すエントリを削除する必要があります。}}
   
  +
例:
For example:
 
   
 
{{hc|/etc/kernel/cmdline|
 
{{hc|/etc/kernel/cmdline|
88行目: 88行目:
 
}}
 
}}
   
{{Tip|The {{ic|bgrt_disable}} parameter tells Linux to not display the OEM logo after loading the ACPI tables.}}
+
{{Tip|{{ic|bgrt_disable}} パラメータは ACPI テーブルをロードした後に OEM ロゴを表示しないように Linux に指示します。}}
   
  +
最後に、[[initramfs]] を再生成します。
Finally, [[regenerate the initramfs]].
 
   
 
=== dracut ===
 
=== dracut ===
   
[[dracut#Kernel command line options|Place your command line parameters]] in ie. {{ic|/etc/dracut.conf.d/cmdline.conf}}
+
[[dracut#カーネルコマンドラインオプション|コマンドラインパラメータを配置]] を、例えば {{ic|/etc/dracut.conf.d/cmdline.conf}} に配置します。
   
  +
画像を生成する。
Generate the image with:
 
   
 
# dracut -f -q --uefi --uefi-splash-image /usr/share/systemd/bootctl/splash-arch.bmp
 
# dracut -f -q --uefi --uefi-splash-image /usr/share/systemd/bootctl/splash-arch.bmp
   
Also see [[dracut#Generate a new initramfs on kernel upgrade]].
+
こちらも参照 [[dracut#カーネルのアップグレード時に新しい initramfs を生成]]
   
=== Manually ===
+
=== 手動で ===
   
  +
使いたいカーネルコマンドラインをファイルに入れて、{{man|1|objcopy}} でバンドルファイルを作成します。
Put the kernel command line you want to use in a file, and create the bundle file using {{man|1|objcopy}}.
 
   
  +
[[マイクロコード]] の場合、まず以下のようにマイクロコードファイルと initrd を連結します。
For [[microcode]], first concatenate the microcode file and your initrd, as follows:
 
   
 
$ cat /boot/''cpu_manufacturer''-ucode.img /boot/initramfs-linux.img > /tmp/combined_initrd.img
 
$ cat /boot/''cpu_manufacturer''-ucode.img /boot/initramfs-linux.img > /tmp/combined_initrd.img
   
  +
Unified カーネルイメージを構築するときに、{{ic|/tmp/combined_initrd.img}} を initrdとして渡します。このファイルは後で作成できます。
When building the unified kernel image, passing {{ic|/tmp/combined_initrd.img}} as the initrd. This file can be afterwards.
 
   
 
{{bc|1=
 
{{bc|1=
122行目: 122行目:
 
}}
 
}}
   
See [https://github.com/systemd/systemd/commit/0fa2cac4f0cdefaf1addd7f1fe0fd8113db9360b#commitcomment-55422970] for an explanation on why these exact numbers were chosen.
+
この正確な数値が選ばれた理由については、[https://github.com/systemd/systemd/commit/0fa2cac4f0cdefaf1addd7f1fe0fd8113db9360b#commitcomment-55422970] を参照してください。
   
  +
イメージを作成したら、EFI システムパーティションにコピーします。
After creating the image, copy it to the EFI system partition:
 
   
 
# cp ''linux''.efi ''esp''/EFI/Linux/
 
# cp ''linux''.efi ''esp''/EFI/Linux/

2022年3月2日 (水) 20:42時点における版

Unified カーネルイメージ は単一の実行ファイルで、UEFI ファームウェアから直接起動したり、ブートローダによってほとんどあるいは全く設定なしで自動的に起動することができます。

Arch がサポートするカーネル自体は can be loaded by UEFI firmware ですが、ユニファイドイメージはそれを組み込むことを可能にします。

出来上がった実行ファイル、つまりこれら全ての要素は、signed で簡単にセキュアブート で使用できるようにすることができます。

ノート: 記事全体で espEFI システムパーティション のマウントポイントを表します。

unified カーネルイメージの準備

mkinitpcio

例として実行することで機能をテストできます

# mkinitcpio -p linux -- --uefi esp/EFI/Linux/test-systemd.efi

これにより、linux プリセットのカーネルイメージが生成されます。

.preset ファイル

まず、EFI システムパーティション の適切なマウントポイントを指定して、 /etc/mkinitcpio.d/linux.preset あるいは使用しているプリセットを以下のように変更します。

  • マイクロコード が必要な場合は、ALL_microcode=(/boot/*-ucode.img) を追加して、mkinitcpio にその場所を追加します。
  • PRESET_efi_image= PRESETS= の各項目に対して、PRESET_efi_image= パラメータを追加します。default_efi_image="esp/EFI/Linux/archlinux-linux.efi"fallback_efi_image="esp/EFI/Linux/archlinux-linux-fallback.efi" の各項目です。これにより、実行ファイル名が設定されます。
  • オプションとして、各 --splash /usr/share/systemd/bootctl/splash-arch.bmp 行に PRESET_options= を追加して、スプラッシュ画像を追加することも可能です、つまり default_options="--splash /usr/share/systemd/bootctl/splash-arch.bmp"fallback_options="-S autodetect --splash /usr/share/systemd/bootctl/splash-arch.bmp" のように指定します。

以下は、linux カーネルと Arch のスプラッシュスクリーンのための linux.preset の動作例です。

/etc/mkinitcpio.d/linux.preset
# mkinitcpio preset file for the 'linux' package

ALL_config="/etc/mkinitcpio.conf"
ALL_kver="/boot/vmlinuz-linux"
ALL_microcode=(/boot/*-ucode.img)

PRESETS=('default' 'fallback')

default_image="/boot/initramfs-linux.img"
default_efi_image="esp/EFI/Linux/archlinux-linux.efi"
default_options="--splash /usr/share/systemd/bootctl/splash-arch.bmp"

fallback_image="/boot/initramfs-linux-fallback.img"
fallback_efi_image="esp/EFI/Linux/archlinux-linux-fallback.efi"
fallback_options="-S autodetect --splash /usr/share/systemd/bootctl/splash-arch.bmp"

この2番目の例では、linux のデフォルトイメージと linux-lts のフォールバックイメージを作成します。

/etc/mkinitcpio.d/linux.preset
ALL_config="/etc/mkinitcpio.conf"
ALL_microcode=(/boot/*-ucode.img)

PRESETS=('default' 'fallback')

default_kver="/boot/vmlinuz-linux"
default_image="/boot/initramfs-linux.img"
default_efi_image="/boot/EFI/Linux/archlinux-linux.efi"
default_options="--splash /usr/share/systemd/bootctl/splash-arch.bmp"

fallback_kver="/boot/vmlinuz-linux-lts"
fallback_image="/boot/initramfs-linux-lts-fallback.img"
fallback_efi_image="/boot/EFI/Linux/archlinux-linux-lts-fallback.efi"
fallback_options="-S autodetect --splash /usr/share/systemd/bootctl/splash-arch.bmp"
ヒント: 複数のカーネルを使用している場合は、ESP に十分なスペースがあることを確認してください。mkinitcpio は現在 initramfs-*。img*.efi実行可能ファイル。これにより、使用されるスペースが2倍になります。 [1] を参照してください。

カーネルコマンドライン

次に、カーネルパラメータ を使用して /etc/kernel/cmdline を作成します。

# cp /proc/cmdline /etc/kernel/cmdline
警告: initrd マイクロコードと initramfs を指すエントリを削除する必要があります。

例:

/etc/kernel/cmdline
rw quiet bgrt_disable
ヒント: bgrt_disable パラメータは ACPI テーブルをロードした後に OEM ロゴを表示しないように Linux に指示します。

最後に、initramfs を再生成します。

dracut

コマンドラインパラメータを配置 を、例えば /etc/dracut.conf.d/cmdline.conf に配置します。

画像を生成する。

# dracut -f -q --uefi --uefi-splash-image /usr/share/systemd/bootctl/splash-arch.bmp

こちらも参照 dracut#カーネルのアップグレード時に新しい initramfs を生成

手動で

使いたいカーネルコマンドラインをファイルに入れて、objcopy(1) でバンドルファイルを作成します。

マイクロコード の場合、まず以下のようにマイクロコードファイルと initrd を連結します。

$ cat /boot/cpu_manufacturer-ucode.img /boot/initramfs-linux.img > /tmp/combined_initrd.img

Unified カーネルイメージを構築するときに、/tmp/combined_initrd.img を initrdとして渡します。このファイルは後で作成できます。

$ objcopy \
    --add-section .osrel="/usr/lib/os-release" --change-section-vma .osrel=0x20000 \
    --add-section .cmdline="/etc/kernel/cmdline" --change-section-vma .cmdline=0x30000 \
    --add-section .splash="/usr/share/systemd/bootctl/splash-arch.bmp" --change-section-vma .splash=0x40000 \
    --add-section .linux="vmlinuz-file" --change-section-vma .linux=0x2000000 \
    --add-section .initrd="initrd-file" --change-section-vma .initrd=0x3000000 \
    "/usr/lib/systemd/boot/efi/linuxx64.efi.stub" "linux.efi"

この正確な数値が選ばれた理由については、[2] を参照してください。

イメージを作成したら、EFI システムパーティションにコピーします。

# cp linux.efi esp/EFI/Linux/

Booting

systemd-boot

systemd-boot searches in esp/EFI/Linux/ for unified kernel images, and there is no further configuration needed. See sd-boot(7) § FILES

Directly from UEFI

efibootmgr can be used to create a UEFI boot entry for the .efi file:

# efibootmgr --create --disk /dev/sdX --part partition_number --label "label" --loader 'EFI\Linux\file.efi' --verbose

See efibootmgr(8) for an explanation of the options.

See also