Chapter 7. Managing kernel command-line parameters with UKI
Unified Kernel Image (UKI) combines the kernel, initial RAM disk (initrd), and boot command line into a single executable binary.
7.1. Understanding kernel command-line parameters with UKI Copy linkLink copied to clipboard!
With UKI, systemd-boot, specifically systemd-stub, handles the kernel command-line parameters. The UKI delivered by Red Hat includes the basic kernel command-line parameter console=tty0 console=ttyS0.
You can add additional kernel command-line parameters by using UKI add-ons. Alternatively, you can generate your own UKI to contain any arguments you require.
Secure Boot revokes improperly signed UKIs and add-ons. These signatures can also alter PCR measurements of TPM which can potentially affect boot sequence.
7.2. Understanding boot entries Copy linkLink copied to clipboard!
You manage boot entries directly in UEFI NVRAM. This means they are no longer stored on disk. You can use tools such as kernel-bootcfg or efibootmgr to alter boot entries directly.
The following is an example of a boot entry:
Boot0001* redhat HD(1,GPT,9192a707-8768-4c9f-bb11-fdd7c7e307e7,0x800,0x100000)/\EFI\redhat\shimx64.efi\EFI\Linux\ffffffffffffffffffffffffffffffff-6.12.0-174.el10.x86_64.efi
Boot0001* redhat HD(1,GPT,9192a707-8768-4c9f-bb11-fdd7c7e307e7,0x800,0x100000)/\EFI\redhat\shimx64.efi\EFI\Linux\ffffffffffffffffffffffffffffffff-6.12.0-174.el10.x86_64.efi
7.3. Acquire UKI add-ons to add kernel command-line parameters Copy linkLink copied to clipboard!
To add kernel command-line parameters, you can acquire officially signed add-ons delivered by Red Hat in the kernel-uki-virt-addons packages. These add-ons are signed by the same certificates as their associated UKIs. The default installation path is /lib/modules/$(uname -r)/vmlinuz-virt.efi.extra.d/.
You must copy these add-ons to the appropriate locations for them to take effect.
If you need add-ons other than these or prefer signing them on your own, you can create them with tools such as systemd-ukify or dracut.
Procedure
Create a new add-on:
ukify build --cmdline "emergency" --output emergency.unsigned.addon.efi
# ukify build --cmdline "emergency" --output emergency.unsigned.addon.efiCopy to Clipboard Copied! Toggle word wrap Toggle overflow
7.4. Changing kernel command-line parameters for all boot entries Copy linkLink copied to clipboard!
To change kernel command-line parameters for all boot entries, add the UKI add-ons to the global add-ons directory /boot/efi/loader/addons/.
Prerequisites
- You have root permissions on the system.
-
You have
.addon.efifile.
Procedure
Copy the add-on file to the
/boot/efi/loader/addons/directory:cp <my-addon>.addon.efi /boot/efi/loader/addons/
# cp <my-addon>.addon.efi /boot/efi/loader/addons/Copy to Clipboard Copied! Toggle word wrap Toggle overflow Reboot the system:
reboot
# rebootCopy to Clipboard Copied! Toggle word wrap Toggle overflow
Verification
Verify the new parameter depends on the type of the added add-on. For example, check the kernel command line:
cat /proc/cmdline
# cat /proc/cmdlineCopy to Clipboard Copied! Toggle word wrap Toggle overflow
7.5. Changing kernel command-line parameters for a single UKI Copy linkLink copied to clipboard!
To change kernel command-line parameters for a single UKI, manage the add-ons on a per-UKI basis. The revocation mechanism applies to UKI and its associated add-ons locally.
By default, UKIs are located at the following path:
/boot/efi/EFI/Linux/<machine_id>-<kernel_version>.efi
The effective add-ons designated to this UKI are located at the following path:
/boot/efi/EFI/Linux/<machine_id>-<kernel_version>.efi.extra.d/
Prerequisites
- You have root permissions on the system.
-
You have
.addon.efifile.
Procedure
Identify the running kernel version and machine ID:
uname -r cat /etc/machine-id
# uname -r # cat /etc/machine-idCopy to Clipboard Copied! Toggle word wrap Toggle overflow Copy the add-on file to the specific directory associated with the UKI:
cp <my-addon>.addon.efi /boot/efi/EFI/Linux/<machine_id>-<kernel_version>.efi.extra.d/
# cp <my-addon>.addon.efi /boot/efi/EFI/Linux/<machine_id>-<kernel_version>.efi.extra.d/Copy to Clipboard Copied! Toggle word wrap Toggle overflow Reboot the system:
reboot
# rebootCopy to Clipboard Copied! Toggle word wrap Toggle overflow
Verification
Verify the new parameter depends on the type of the added add-on. For example, check the kernel command line:
cat /proc/cmdline
# cat /proc/cmdlineCopy to Clipboard Copied! Toggle word wrap Toggle overflow
When you update the kernel-uki-virt package, the system installs a new UKI version. The update also copies the currently effective add-ons to the directory for the new UKI, provided that the kernel-uki-virt-addons package is installed at the same time. This happens automatically, for example, when you run dnf update.
7.6. Creating UKI to contain customized kernel command-line parameters Copy linkLink copied to clipboard!
To customize the Linux kernel, initial RAM disk, or initrd, and kernel command-line parameters, you can create your own UKI by using tools such as systemd-ukify or dracut.
Procedure
For example, to create a custom UKI by using
systemd-ukify:ukify build --initrd /boot/initramfs-$(uname -r).img --linux /lib/modules/$(uname -r)/vmlinuz --uname $(uname -r) --cmdline "console=tty0 console=ttyS0 emergency" --output uki.unsigned.efi
# ukify build --initrd /boot/initramfs-$(uname -r).img --linux /lib/modules/$(uname -r)/vmlinuz --uname $(uname -r) --cmdline "console=tty0 console=ttyS0 emergency" --output uki.unsigned.efiCopy to Clipboard Copied! Toggle word wrap Toggle overflow