How Ubuntu installkernel Deploys Linux Kernel Images

Overview

When building or deploying custom kernels on Ubuntu, the installkernel utility handles placing kernel artifacts into their proper system locations. This hands-on walkthrough examines how the tool is structured under the hood, demonstrates its required arguments and custom target directory behavior, and shows how it preserves existing binaries with .old backups before triggering post-installation hooks.

Locating installkernel and Inspecting Its Script

Before experimenting with installkernel, ensure the debianutils package—which provides the utility—is available on your system.

Installing the debianutils package via apt-get

Next, locate the binary on your PATH by running which installkernel.
The output confirms that the executable resides at /usr/sbin/installkernel.

Locating the installkernel executable path

Inspect the opening 35 lines of the file with head -n 35 /usr/sbin/installkernel.
As the header and comments reveal, installkernel is actually a /bin/sh shell script rather than a compiled binary. When you run make install from a Linux kernel source tree, the build system invokes this script to copy the compiled kernel image and metadata into the standard Debian-style directories.

Viewing the first 35 lines of /usr/sbin/installkernel

Understanding Required Arguments and Preparing Test Artifacts

Invoking installkernel 2>&1 || true with no parameters prints its usage signature.
The message Usage: installkernel <version> <image> <System.map> <directory> indicates that the script expects four positional arguments: a kernel version string, the kernel image file, the corresponding System.map file, and a destination directory.

Checking installkernel usage output without arguments

To keep the experiment isolated from the host’s /boot partition, create a dedicated staging directory using mkdir -p /tmp/kernel_lab/boot_target.

Creating a temporary target directory for kernel testing

Generate a placeholder kernel image file for testing with echo "dummy_kernel_binary" > /tmp/kernel_lab/bzImage-test.

Creating a dummy kernel image file

Create a matching mock System.map file alongside it by running echo "00000000 T _text" > /tmp/kernel_lab/System.map-test.

Creating a mock System.map file

Deploying to a Custom Directory and Observing .old Backups

Now pass the 6.8.0-custom version string, the dummy kernel image, the mock System.map, and /tmp/kernel_lab/boot_target to the script via installkernel 6.8.0-custom /tmp/kernel_lab/bzImage-test /tmp/kernel_lab/System.map-test /tmp/kernel_lab/boot_target || true.
The command completes silently without errors, copying the artifacts into the specified target path.

Running installkernel with a custom target directory

Verify the deployment by listing the target folder with ls -la /tmp/kernel_lab/boot_target.
Notice that the script automatically renames the files using the supplied version string, producing vmlinuz-6.8.0-custom and System.map-6.8.0-custom.

Verifying installed kernel files in the target directory

To see how the utility handles overwriting an identical kernel version, execute installkernel 6.8.0-custom /tmp/kernel_lab/bzImage-test /tmp/kernel_lab/System.map-test /tmp/kernel_lab/boot_target || true a second time.
Rather than discarding the previous files, installkernel rotates them into backups before writing the new copies.

Re-running installkernel for the same kernel version

Check the directory contents again with ls -la /tmp/kernel_lab/boot_target.
The earlier artifacts are preserved as vmlinuz-6.8.0-custom.old and System.map-6.8.0-custom.old right alongside the newly installed files.

Confirming .old backup files after re-running installkernel

Post-Installation Hooks (/etc/kernel/postinst.d) and Cleanup

After placing the kernel files, installkernel looks for hook scripts to run automatically—such as initramfs generators or bootloader updaters. Inspect the hook directory using ls -la /etc/kernel/postinst.d/.
In this environment, only . and .. appear, confirming that no custom scripts are currently registered inside /etc/kernel/postinst.d/.

Checking the /etc/kernel/postinst.d/ hook directory

Finally, remove the temporary workspace and mock files by running rm -rf /tmp/kernel_lab.

Cleaning up the temporary kernel lab directory

Understanding how installkernel names, backs up, and hooks kernel artifacts makes manual kernel compilation and deployment on Ubuntu much more predictable. With these mechanics clear, you can safely test custom builds or troubleshoot make install behavior whenever needed.