LinuxCommandLibrary

kernel-install

Install kernel and initramfs for bootloaders

TLDR

Add kernel and initramfs images to bootloader partition

$ sudo kernel-install add [kernel-version] [kernel-image] [path/to/initrd-file ...]
copy

Remove kernel from the bootloader partition
$ sudo kernel-install remove [kernel-version]
copy

Show various paths and parameters that have been configured or auto-detected
$ sudo kernel-install inspect [kernel-image]
copy

SYNOPSIS

kernel-install add VERSION-NR KERNEL-IMAGE-PATH [MACHINE-ID]
kernel-install remove VERSION-NR [MACHINE-ID]
kernel-install inspect [MACHINE-ID]
kernel-install list [MACHINE-ID]
kernel-install [OPTIONS...]

PARAMETERS

--root=PATH
    Use alternate filesystem root for operations.

--image=PATH
    Operate on mounted OS image tree.

--vroot=DIR
    Use directory as virtual root for operations.

-h, --help
    Print short help text.

-V, --version
    Print version string.

DESCRIPTION

kernel-install is a systemd tool for standardizing the installation, removal, and inspection of Linux kernel images across distributions. It handles placing kernels and initramfs into /boot (or EFI partitions), running hook scripts for tasks like depmod, initramfs generation, and bootloader updates.

Using add VERSION-NR KERNEL-IMAGE-PATH, it creates /boot/VERSION-NR/ with symlinks to vmlinuz, initrd, and config files, executing phased scripts from /usr/lib/kernel/install.d/ (e.g., 50-depmod.install, 99-default.install) and /etc/kernel/install.d/ for customization. Bootloaders like GRUB or systemd-boot are updated via presets.

remove cleans up directories and configs; inspect checks installation status; list enumerates kernels. This ensures consistent kernel management, especially for DKMS modules, custom builds, or package managers triggering installs.

It integrates with dracut, mkinitcpio, or update-initramfs, making it ideal for Arch, Fedora, openSUSE, and Debian derivatives adopting systemd-boot.

CAVEATS

Requires hooks in /usr/lib/kernel/install.d/ for full functionality; not all distros configure out-of-box. Initramfs generation depends on dracut/mkinitcpio presence. Use with booted system or chroot carefully.

HOOK PHASES

Scripts run in order: 00-initrd.install (initramfs), 50-depmod.install (modules), 90-loaderentry.install (bootloader config), 99-default.install. Place custom in /etc/kernel/install.d/.

KERNEL LAYOUT

Installs to /boot/<version>/ with vmlinuz-<version>, initrd.img-<version>, System.map, config symlinks.

HISTORY

Introduced in systemd 243 (Nov 2019) to unify kernel management amid bootloader diversity. Evolved with EFI support, phased hooks, and integration for rpm/deb packages in Fedora, openSUSE.

SEE ALSO

Copied to clipboard