table of contents
- bookworm-backports 254.16-1~bpo12+1
- testing 256.5-1
- unstable 256.5-2
UKIFY(1) | ukify | UKIFY(1) |
NAME¶
ukify - Combine components into a signed Unified Kernel Image for UEFI systems
SYNOPSIS¶
/usr/lib/systemd/ukify [OPTIONS...] build
ukify [OPTIONS...] genkey
DESCRIPTION¶
Note: this command is experimental for now. While it is intended to become a regular component of systemd, it might still change in behaviour and interface.
ukify is a tool whose primary purpose is to combine components (usually a kernel, an initrd, and a UEFI boot stub) to create a Unified Kernel Image (UKI)[1] — a PE binary that can be executed by the firmware to start the embedded linux kernel. See systemd-stub(7) for details about the stub.
COMMANDS¶
The following commands are understood:
build¶
This command creates a Unified Kernel Image. The two primary options that should be specified for the build verb are Linux=/--linux=, and Initrd=/--initrd=. Initrd= accepts multiple whitespace-separated paths and --initrd= can be specified multiple times.
Additional sections will be inserted into the UKI, either automatically or only if a specific option is provided. See the discussions of Cmdline=/--cmdline=, OSRelease=/--os-release=, DeviceTree=/--devicetree=, Splash=/--splash=, PCRPKey=/--pcrpkey=, Uname=/--uname=, SBAT=/--sbat=, and --section= below.
ukify can also be used to assemble a PE binary that is not executable but contains auxiliary data, for example additional kernel command line entries.
If PCR signing keys are provided via the PCRPrivateKey=/--pcr-private-key= and PCRPublicKey=/--pcr-public-key= options, PCR values that will be seen after booting with the given kernel, initrd, and other sections, will be calculated, signed, and embedded in the UKI. systemd-measure(1) is used to perform this calculation and signing.
The calculation of PCR values is done for specific boot phase paths. Those can be specified with the Phases=/--phases= option. If not specified, the default provided by systemd-measure is used. It is also possible to specify the PCRPrivateKey=/--pcr-private-key=, PCRPublicKey=/--pcr-public-key=, and Phases=/--phases= arguments more than once. Signatures will then be performed with each of the specified keys. On the command line, when both --phases= and --pcr-private-key= are used, they must be specified the same number of times, and then the n-th boot phase path set will be signed by the n-th key. This can be used to build different trust policies for different phases of the boot. In the config file, PCRPrivateKey=, PCRPublicKey=, and Phases= are grouped into separate sections, describing separate boot phases.
If a SecureBoot signing key is provided via the SecureBootPrivateKey=/--secureboot-private-key= option, the resulting PE binary will be signed as a whole, allowing the resulting UKI to be trusted by SecureBoot. Also see the discussion of automatic enrollment in systemd-boot(7).
If the stub and/or the kernel contain ".sbat" sections they will be merged in the UKI so that revocation updates affecting either are considered when the UKI is loaded by Shim. For more information on SBAT see Shim's documentation.[2]
genkey¶
This command creates the keys for PCR signing and the key and certificate used for SecureBoot signing. The same configuration options that determine what keys and in which paths will be needed for signing when build is used, here determine which keys will be created. See the discussion of PCRPrivateKey=/--pcr-private-key=, PCRPublicKey=/--pcr-public-key=, and SecureBootPrivateKey=/--secureboot-private-key= below.
The output files must not exist.
CONFIGURATION SETTINGS¶
Settings can appear in configuration files (the syntax with SomeSetting=value) and on the command line (the syntax with --some-setting=value). For some command line parameters, a single-letter shortcut is also allowed. In the configuration files, the setting must be in the appropriate section, so the descriptions are grouped by section below. When the same setting appears in the configuration file and on the command line, generally the command line setting has higher priority and overwrites the config file setting completely. If some setting behaves differently, this is described below.
The LINUX and INITRD positional arguments, or the equivalent Linux= and Initrd= settings, are optional. If more than one initrd is specified, they will all be combined into a single PE section. This is useful to, for example, prepend microcode before the actual initrd.
The following options and settings are understood:
Commandline-only options¶
--config=PATH
--measure, --no-measure
--section=NAME:TEXT|@PATH
--tools=DIRS
--output=FILENAME
--summary
-h, --help
--version
[UKI] section¶
Linux=LINUX, --linux=LINUX
Initrd=INITRD..., --initrd=LINUX
Cmdline=TEXT|@PATH, --cmdline=TEXT|@PATH
OSRelease=TEXT|@PATH, --os-release=TEXT|@PATH
DeviceTree=PATH, --devicetree=PATH
Splash=PATH, --splash=PATH
PCRPKey=PATH, --pcrpkey=PATH
Uname=VERSION, --uname=VERSION
PCRBanks=PATH, --pcr-banks=PATH
SecureBootSigningTool=SIGNER, --signtool=SIGNER
SecureBootPrivateKey=SB_KEY, --secureboot-private-key=SB_KEY
SecureBootCertificate=SB_CERT, --secureboot-certificate=SB_CERT
SecureBootCertificateDir=SB_PATH, --secureboot-certificate-dir=SB_PATH
SecureBootCertificateName=SB_CERTNAME, --secureboot-certificate-name=SB_CERTNAME
SecureBootCertificateValidity=DAYS, --secureboot-certificate-validity=DAYS
SigningEngine=ENGINE, --signing-engine=ENGINE
SignKernel=BOOL, --sign-kernel, --no-sign-kernel
SBAT=TEXT|@PATH, --sbat=TEXT|@PATH
[PCRSignature:NAME] section¶
In the config file, those options are grouped by section. On the commandline, they must be specified in the same order. The sections specified in both sources are combined.
PCRPrivateKey=PATH, --pcr-private-key=PATH
PCRPublicKey=PATH, --pcr-public-key=PATH
On the commandline, this option may be specified more than once, similarly to the --pcr-private-key= option. If not present, the public keys will be extracted from the private keys. On the commandline, if present, the this option must be specified the same number of times as the --pcr-private-key= option.
Phases=LIST, --phases=LIST
On the commandline, when this argument is present, it must appear the same number of times as the --pcr-private-key= option.
EXAMPLES¶
Example 1. Minimal invocation
$ ukify build \
--linux=/lib/modules/6.0.9-300.fc37.x86_64/vmlinuz \
--initrd=/some/path/initramfs-6.0.9-300.fc37.x86_64.img \
--cmdline='quiet rw'
This creates an unsigned UKI ./vmlinuz.unsigned.efi.
Example 2. All the bells and whistles
$ /usr/lib/systemd/ukify build \
--linux=/lib/modules/6.0.9-300.fc37.x86_64/vmlinuz \
--initrd=early_cpio \
--initrd=/some/path/initramfs-6.0.9-300.fc37.x86_64.img \
--sbat='sbat,1,SBAT Version,sbat,1,https://github.com/rhboot/shim/blob/main/SBAT.md
uki.author.myimage,1,UKI for System,uki.author.myimage,1,https://uapi-group.org/specifications/specs/unified_kernel_image/' \
--pcr-private-key=pcr-private-initrd-key.pem \
--pcr-public-key=pcr-public-initrd-key.pem \
--phases='enter-initrd' \
--pcr-private-key=pcr-private-system-key.pem \
--pcr-public-key=pcr-public-system-key.pem \
--phases='enter-initrd:leave-initrd enter-initrd:leave-initrd:sysinit \
enter-initrd:leave-initrd:sysinit:ready' \
--pcr-banks=sha384,sha512 \
--secureboot-private-key=sb.key \
--secureboot-certificate=sb.cert \
--sign-kernel \
--cmdline='quiet rw rhgb'
This creates a signed UKI ./vmlinuz.signed.efi. The initrd section contains two concatenated parts, early_cpio and initramfs-6.0.9-300.fc37.x86_64.img. The policy embedded in the ".pcrsig" section will be signed for the initrd (the enter-initrd phase) with the key pcr-private-initrd-key.pem, and for the main system (phases leave-initrd, sysinit, ready) with the key pcr-private-system-key.pem. The Linux binary and the resulting combined image will be signed with the SecureBoot key sb.key.
Example 3. All the bells and whistles, via a config file
This is the same as the previous example, but this time the configuration is stored in a file:
$ cat ukify.conf [UKI] Initrd=early_cpio Cmdline=quiet rw rhgb SecureBootPrivateKey=sb.key SecureBootCertificate=sb.cert SignKernel=yes PCRBanks=sha384,sha512 [PCRSignature:initrd] PCRPrivateKey=pcr-private-initrd-key.pem PCRPublicKey=pcr-public-initrd-key.pem Phases=enter-initrd [PCRSignature:system] PCRPrivateKey=pcr-private-system-key.pem PCRPublicKey=pcr-public-system-key.pem Phases=enter-initrd:leave-initrd
enter-initrd:leave-initrd:sysinit
enter-initrd:leave-initrd:sysinit:ready $ /usr/lib/systemd/ukify -c ukify.conf build \
--linux=/lib/modules/6.0.9-300.fc37.x86_64/vmlinuz \
--initrd=/some/path/initramfs-6.0.9-300.fc37.x86_64.img
One "initrd" (early_cpio) is specified in the config file, and the other initrd (initramfs-6.0.9-300.fc37.x86_64.img) is specified on the commandline. This may be useful for example when the first initrd contains microcode for the CPU and does not need to be updated when the kernel version changes, unlike the actual initrd.
Example 4. Kernel command line PE addon
ukify build \
--secureboot-private-key=sb.key \
--secureboot-certificate=sb.cert \
--cmdline='debug' \
--sbat='sbat,1,SBAT Version,sbat,1,https://github.com/rhboot/shim/blob/main/SBAT.md
uki-addon.author,1,UKI Addon for System,uki-addon.author,1,https://www.freedesktop.org/software/systemd/man/systemd-stub.html'
--output=debug.addon.efi
This creates a signed PE binary that contains the additional kernel command line parameter "debug" with SBAT metadata referring to the owner of the addon.
Example 5. Decide signing policy, and create certificate and keys
First, let's create a configuration file that specifies what signatures shall be made:
# cat >/etc/kernel/uki.conf <<EOF [UKI] SecureBootPrivateKey=/etc/kernel/secure-boot.key.pem SecureBootCertificate=/etc/kernel/secure-boot.cert.pem [PCRSignature:initrd] Phases=enter-initrd PCRPrivateKey=/etc/kernel/pcr-initrd.key.pem PCRPublicKey=/etc/kernel/pcr-initrd.pub.pem [PCRSignature:system] Phases=enter-initrd:leave-initrd enter-initrd:leave-initrd:sysinit
enter-initrd:leave-initrd:sysinit:ready PCRPrivateKey=/etc/kernel/pcr-system.key.pem PCRPublicKey=/etc/kernel/pcr-system.pub.pem EOF
Next, we can generate the certificate and keys:
# /usr/lib/systemd/ukify genkey --config=/etc/kernel/uki.conf Writing SecureBoot private key to /etc/kernel/secure-boot.key.pem Writing SecureBoot certificate to /etc/kernel/secure-boot.cert.pem Writing private key for PCR signing to /etc/kernel/pcr-initrd.key.pem Writing public key for PCR signing to /etc/kernel/pcr-initrd.pub.pem Writing private key for PCR signing to /etc/kernel/pcr-system.key.pem Writing public key for PCR signing to /etc/kernel/pcr-system.pub.pem
(Both operations need to be done as root to allow write access to /etc/kernel/.)
Subsequent invocations of using the config file (/usr/lib/systemd/ukify build --config=/etc/kernel/uki.conf) will use this certificate and key files. Note that the kernel-install(8) plugin 60-ukify.install uses /etc/kernel/uki.conf by default, so after this file has been created, installations of kernels that create a UKI on the local machine using kernel-install would perform signing using this config.
SEE ALSO¶
systemd(1), systemd-stub(7), systemd-boot(7), systemd-measure(1), systemd-pcrphase.service(8)
NOTES¶
- 1.
- Unified Kernel Image (UKI)
- 2.
- Shim's documentation.
systemd 254 |