kernel-install
Install kernel and initramfs for bootloaders
TLDR
Add kernel and initramfs images to bootloader partition
Remove kernel from the bootloader partition
Show various paths and parameters that have been configured or auto-detected
SYNOPSIS
kernel-install [OPTIONS...] COMMAND KERNEL_VERSION IMAGE_FILE [INITRD_FILE]
PARAMETERS
COMMAND
The action to perform. Common commands are: add to install a new kernel and its associated files, and remove to remove an existing kernel.
KERNEL_VERSION
The kernel version string (e.g., '6.5.0-generic') to use for the installation or removal. This version dictates the filenames and directory structures.
IMAGE_FILE
The path to the kernel image file (e.g., vmlinuz or bzImage) to be installed. Required for the add command.
INITRD_FILE
Optional path to a pre-built initramfs file. If not provided, kernel-install will usually trigger a hook to generate one.
--dry-run
Perform a trial run with no changes made. Only shows what would happen.
--no-sync
Do not synchronize filesystem changes after operations. This is generally not recommended for production systems.
--loader-entry-token=TOKEN
Specify a unique token for the loader entry. By default, the machine-id is used.
--boot-option=OPTION
Add a kernel command line option to the boot loader entry. Can be specified multiple times.
DESCRIPTION
kernel-install is a command-line utility designed to automate the process of installing new kernel and initramfs images onto a Linux system. It primarily serves as a standardized interface for package managers or custom build scripts to integrate newly compiled or installed kernels with the boot loader.
The command typically copies the kernel image (vmlinuz) and its associated initial RAM disk (initrd) to a location accessible by the boot loader, often under /boot or /efi/EFI/Linux. It then invokes helper scripts (hooks) located in /usr/lib/kernel/install.d/ and /etc/kernel/install.d/ to perform additional tasks, such as generating the initramfs using tools like dracut or mkinitcpio, and updating boot loader configurations (e.g., creating systemd-boot entries or updating GRUB).
Its goal is to provide a robust and consistent method for managing kernel updates, ensuring the system remains bootable without manual intervention for boot loader configuration.
CAVEATS
kernel-install relies heavily on the /usr/lib/kernel/install.d/ and /etc/kernel/install.d/ hook scripts for its functionality. Without these hooks, it may only copy files without generating initramfs or updating boot loader configurations. It's primarily designed for systems that use the Boot Loader Specification and often integrates best with systemd-boot or GRUB.
The behavior can vary significantly depending on the distribution and installed hook scripts. Misconfigured or missing hooks can lead to unbootable systems.
HOOK SCRIPTS
kernel-install executes scripts found in /usr/lib/kernel/install.d/ and /etc/kernel/install.d/, sorted by filename. These scripts are responsible for tasks like generating initramfs (e.g., 90-dracut.install), copying kernel images, and updating boot loader entries. Users can place their own scripts in /etc/kernel/install.d/ to customize the installation process.
BOOT LOADER SPECIFICATION
The command adheres to the Boot Loader Specification, a standard for how boot loaders discover and interpret boot entries. This promotes interoperability between different boot loaders and operating systems, allowing kernel-install to manage boot entries in a standardized manner, often generating .conf files in /boot/loader/entries/ for systemd-boot.
MACHINE ID
By default, kernel-install uses the system's unique machine ID (read from /etc/machine-id) as part of the directory structure and filenames for installed kernels. This ensures that multiple kernels can coexist cleanly and uniquely identify their respective entries, especially important in multi-boot or snapshot scenarios.
HISTORY
kernel-install is part of the systemd project and was introduced to standardize the process of kernel installation and removal. Prior to its existence, each Linux distribution often had its own scripts and conventions for managing kernel updates, leading to inconsistencies. Its development aimed to simplify and unify this process, especially for systems utilizing systemd-boot and adhering to the Boot Loader Specification. It gained prominence as systemd became widely adopted, offering a more robust and predictable mechanism for kernel lifecycle management.
SEE ALSO
dracut(8), mkinitcpio(8), bootctl(1), systemd-boot(7), grub-mkconfig(8), systemd(1)