kernel-install

From ArchWiki

kernel-install(8) is a flexible utility designed to streamline the installation and administration of Linux kernel images on a system. It features a plugin system, allowing for seamless integration with other utilities. These plugins define a range of actions and configurations required during the installation and management of Linux kernel images. Examples of such tasks include configuring boot loader entries, generating Unified kernel images (UKI), or facilitating kernel signing for Secure Boot compliance.

Note: kernel-install itself doesn't generate the initramfs, but utilizes plugins from programs like mkinitcpio or dracut instead.

Installation

kernel-install is part of and packaged with systemd. The systemd-ukify optional dependency is also needed for unified kernel images unless a different UKI generator is specified (see #Main configuration).

Configuration

Main configuration

The main configuration file is /etc/kernel/install.conf. Use it to configure the layout you want to use, i.e. bls for traditional split kernel and initrd images, or uki for Unified kernel images:

/etc/kernel/install.conf
layout=bls
Note: By default, mkinitcpio will generate the initrd, and (if the layout is set to uki) ukify will generate the UKI. This can be changed with initrd_generator= and uki_generator=, see kernel-install(8).
Tip: # kernel-install inspect --verbose can be used to see more information about why some defaults are automatically being used.

Kernel command line

Kernel parameters must be set in /etc/kernel/cmdline. They will either be embedded in the UKI, or added to the boot loader configuration, according to the layout used. If /etc/kernel/cmdline doesn't exist, kernel install will use the parameters in /usr/lib/kernel/cmdline or /proc/cmdline, not setting the kernel parameters in /etc/kernel/cmdline could result in kernel-install using the parameters of the current running kernel.

Plugins

To list active plugins used by kernel-install when installing, upgrading, or removing a kernel image, you can use the inspect argument:

# kernel-install inspect
...
Plugins: /usr/lib/kernel/install.d/50-depmod.install
         /usr/lib/kernel/install.d/50-mkinitcpio.install
         /usr/lib/kernel/install.d/60-ukify.install
         /usr/lib/kernel/install.d/90-loaderentry.install
         /usr/lib/kernel/install.d/90-uki-copy.install
...

Available plugins are found under /usr/lib/kernel/install.d/:

ls /usr/lib/kernel/install.d/
50-depmod.install  50-mkinitcpio.install  60-ukify.install  90-loaderentry.install  90-uki-copy.install  91-sbctl.install

Similarly named files in /etc/kernel/install.d/ will override the default ones.

For example, to disable the default sbctl plugin (which automatically signs new UKIs for Secure Boot):

# ln -sf /dev/null /etc/kernel/install.d/91-sbctl.install

You can also write your own kernel-install plugins, and place them in /etc/kernel/install.d/.

Unified kernel images

See Unified kernel image#kernel-install

Usage

Manually

To manually install a kernel from /usr/lib/modules, use the following add command:

# kernel-install add A.B.C-name /usr/lib/modules/A.B.C-name/vmlinuz
Tip: use # kernel-install add-all to add all installed kernels in one run.

To remove a kernel manually, use the remove command:

# kernel-install remove A.B.C-name

Automatically

To trigger kernel-install and all active plugins automatically when a kernel package is installed or updated, you can install pacman-hook-kernel-installAUR.

It's worth noting that a similar functionality is already provided by mkinitcpio's pacman hooks. If you intend to switch to kernel-install, these will need to be manually masked:

# ln -s /dev/null /etc/pacman.d/hooks/60-mkinitcpio-remove.hook
# ln -s /dev/null /etc/pacman.d/hooks/90-mkinitcpio-install.hook

To revert, simply delete the symlinks created above.