Core Architecture: What Is a UKI?#
A UKI (Unified Kernel Image) combines a UEFI boot stub, Linux kernel, initial RAM filesystem, and optional resources into a single .efi executable. It can include microcode, a command line, system identification, and a splash screen.
Reasons to Choose a UKI
- Signature coverage of components: a signed UKI verified by Secure Boot can protect its kernel and initramfs. The protection still depends on trusted certificates, firmware policy, and the boot chain; it does not guarantee that arbitrary configuration files cannot be exploited.
- Version coupling: keeping the kernel and initramfs together reduces mismatches between separate files; generation and upgrade failures still require a recovery entry point.
- Automatic discovery: systemd-boot can discover conforming UKIs under
/EFI/Linux/on the ESP or XBOOTLDR partition.
UKI Generation Workflow#
Choosing Tools
mkinitcpio can generate UKIs; with systemd-ukify installed, ukify can assemble them. Choose one generation pipeline to avoid multiple tools overwriting each other's output.
sudo pacman -S systemd-ukify sbctl tpm2-toolsThese are example tools for the approach used in this article; they do not imply that every Arch installation must use a TPM.
Kernel Command Line
For example, /etc/kernel/cmdline:
root=UUID=<ROOT_FILESYSTEM_UUID> rw quiet loglevel=3Replace placeholders and add the parameters required by your encryption and subvolume layout. loader.conf still controls boot-loader settings such as the menu and default entry; it does not configure the command line embedded in the UKI.
mkinitcpio Presets
Retain fields such as the kernel path from the complete preset provided by the installed kernel, and adjust the UKI output. For example:
PRESETS=('default' 'fallback')
default_uki="/efi/EFI/Linux/arch-linux.efi"
default_options="--splash /usr/share/systemd/bootctl/splash-arch.bmp"
fallback_uki="/efi/EFI/Linux/arch-linux-fallback.efi"
fallback_options="-S autodetect"/efi is the ESP mount point in this example. Confirm that it is mounted, the directory exists, and unnecessary duplicate initramfs output is disabled in the corresponding preset. Not every version generates a fallback preset; choose according to the actual version.
sudo mkinitcpio -PSuccessful generation does not mean the system has booted from that image. After rebooting, check the running kernel and boot entry.
Initializing and Checking systemd-boot#
In a UEFI environment, with the ESP mounted correctly and recovery media available:
sudo bootctl install
bootctl listInstallation writes to the ESP and may create firmware boot entries. For automatic updates, also check whether systemd-boot-update.service is actually enabled and verify the signing workflow. Running bootctl install alone does not complete all maintenance configuration.
Secure Boot Signing Workflow#
Key Creation, Enrollment, and Saving Signing Paths
Read the device's firmware documentation first, back up the existing keys, and preserve recovery options. The firmware must allow entering Setup Mode. Replacing keys incorrectly may prevent some devices' Option ROMs, displays, or other operating systems from starting.
sudo sbctl create-keys
sudo sbctl enroll-keys -m
sudo sbctl sign -s /efi/EFI/Linux/arch-linux.efi
sudo sbctl verify-m adds Microsoft certificates, a trade-off between compatibility and the scope of trust. sign -s saves file paths for subsequent signing workflows. Automatic re-signing after updates also depends on sbctl's mkinitcpio, kernel-install, or pacman hooks actually taking effect.
TPM2 Measurements and Disk Unlocking#
systemd-stub measures UKI components into PCR 11. Static PCR binding ties key unsealing to selected measurement values; it is not a blanket proof that “the system has never been tampered with.”
# 示例:必须替换设备并先保留可用的 LUKS 口令或恢复密钥
sudo systemd-cryptenroll --tpm2-device=auto --tpm2-pcrs=7+11 /dev/EXAMPLE_LUKS_PARTITIONDirect binding to PCR 11 may stop working after a UKI update, and measurement values continue changing during boot phases. Design a signed PCR policy or another supported strategy for the actual systemd version, and test updates, firmware changes, and recovery paths. TPM-based automatic unlocking also does not replace access controls on the running system.
Boot Flow#
graph TD
UEFI[UEFI 固件] --> SB{验证启动文件签名}
SB -- 成功 --> UKI[运行 UKI]
SB -- 失败 --> HALT[拒绝此启动文件]
UKI --> TPM[扩展 TPM PCR 测量]
TPM --> POLICY{解锁策略匹配}
POLICY -- 成功 --> LUKS[解锁 LUKS]
POLICY -- 失败 --> RECOVERY[口令或恢复密钥]
LUKS --> OS[进入系统]References & further reading
- ArchWiki: Unified kernel image ↗
- ArchWiki: Systemd-boot ↗
- ArchWiki: Unified Extensible Firmware Interface/Secure Boot ↗
- ArchWiki: Trusted Platform Module ↗
Adapted from technical notes. Examples use generic names.
Continue along a reading path
Arch Linux
- 01Arch Linux philosophy and installation planning
- 02Kernel management, systemd-boot, and UKIs
- 03Pacman hooks, the AUR, and build security
- 04Btrfs subvolume layouts and Snapper snapshots
- 05Hardening with LUKS2, Secure Boot, and TPM2
- 06Performance choices and an everyday maintenance checklist
- 07Common Pacman commands and how to remember their flags
- 08Diagnosing slow Pacman downloads and choosing mirrors
- 09informant: Arch news and Pacman hooks
- 10Arch Linux with Btrfs: manual installation and archinstall
- 11Configuring GNOME, input methods, and snapshots
- 12GNOME laptop management and desktop customization
- 13KVM, GPU passthrough, and gaming on Arch Linux
- 14Swap, kernels, and troubleshooting on an Arch desktop