Guest kernels
Every cairn machine boots a Linux kernel that cairn supplies, not the one on your host. By default this is a pinned, checksummed kernel that cairn downloads for you. You can instead boot a kernel you built. This page covers both, the checks cairn applies to a custom kernel, and how kernels are stored.
The default kernel
cairn pins one kernel, 6.1.155 (a Firecracker CI build, x86_64, 44,279,576 bytes). You normally do nothing: the first deploy downloads it, checks its length and sha256, and saves it read-only as $CAIRN_HOME/kernels/vmlinux-6.1.155 (~/.cairn/kernels/ when CAIRN_HOME is unset). The download uses curl, so curl must be installed. Two commands manage it by hand:
cairn kernel fetch # download it now
cairn kernel install ./vmlinux-6.1.155 # offline: install a copy you already haveBoth write the same way: a temporary file, then the length and sha256 are checked, the file is made mode 0444, synced and renamed into place. A wrong length or digest saves nothing. Both take --name <NAME> to name a known kernel (today there is only 6.1.155, which is the default) and --json. Running either when the kernel is already installed and valid changes nothing and says so. A second fetch that starts while one is running waits for the first, so two first deploys do not download twice.
For a source build, make install-kernel does the same download with curl and a checksum test. Run it as yourself, not as root: the kernel file must be yours.
In a manifest, [vm] kernel = "6.1.155" names this pin; omitting it means the same. See manifest for the [vm] table.
Use a custom kernel
Put an uncompressed x86_64 Linux vmlinux in the project and name it in cairn.toml:
app = "hello"
image = "docker.io/library/nginx:1.27"
[vm]
kernel_file = "kernels/vmlinux"
# Optional: kernel_sha256 = "<the file's 64 lowercase hex digits>"cairn deploy --dry-run
cairn deploy
cairn status helloThe dry run works before the kernel has been built. A real deploy checks the file before it pulls or builds the image, then imports it once into $CAIRN_HOME/kernels/custom/<sha256>. Your source file is left unchanged. The status row shows the kernel's Linux release, its digest and the original path.
Rules for the manifest keys:
kernel_fileis relative to the directory that holdscairn.toml. It must stay inside that project, including when it is reached through symlinks. Use relative links: an absolute symlink is refused even when its target is inside the project.kernel(a pin name) andkernel_fileexclude each other.kernel_sha256is optional and valid only withkernel_file. A mismatch refuses the deploy, including when the file was imported before. Get the value withsha256sum kernels/vmlinux.
To use a file anywhere on the host, without editing the manifest:
cairn deploy --kernel-file ../linux/vmlinuxA relative path here is relative to your shell's current directory. The flag replaces all three manifest keys (kernel, kernel_file and kernel_sha256), so the manifest's checksum is not applied to the file the flag selects.
Kernel requirements
Use the top-level vmlinux from a kernel build, not arch/x86/boot/bzImage and not a distro's compressed /boot/vmlinuz. The file must be:
- an uncompressed x86_64 ELF executable,
- at most 128 MiB,
- carrying a Linux version banner of 5.14 or later (
cairn execneedscgroup.kill, which arrived in 5.14).
A kernel built with debug information is usually larger than 128 MiB. Make a stripped copy:
objcopy --strip-debug vmlinux vmlinux.strippedcairn boots without an initramfs, so these options must be built in (=y), not modules:
| Purpose | Options |
|---|---|
| Programs and disks | BINFMT_ELF, VIRTIO_MMIO, VIRTIO_BLK, EXT4_FS |
| Events and exec | VIRTIO_VSOCKETS, CGROUPS, SIGNALFD |
| Networking, including network-off boot setup | VIRTIO_NET, IP_PNP, UNIX, INET |
| Guest filesystems and users | PROC_FS, SYSFS, DEVTMPFS, TMPFS, MULTIUSER |
| Console and terminals | TTY, UNIX98_PTYS, SERIAL_8250_CONSOLE |
| Graceful stop | SERIO_I8042, KEYBOARD_ATKBD, VT |
| Device discovery | Both ACPI and PCI, or VIRTIO_MMIO_CMDLINE_DEVICES |
Firecracker's 6.1 guest configuration is a good starting point for your own build: take it, run make olddefconfig, then make vmlinux.
Optional: the balloon
The memory balloon is not required. If you want memory the guest frees to return to the host, build in VIRTIO_BALLOON, MEMORY_BALLOON (called BALLOON from Linux 7.x; either name counts) and PAGE_REPORTING (=y). A kernel without them boots and runs; it only keeps its memory. CONFIG_INIT_ON_FREE_DEFAULT_ON=y turns free page reporting off under Firecracker, which does not offer VIRTIO_BALLOON_F_PAGE_POISON. cairn warns about either problem when such a kernel is deployed with the balloon on. It never refuses, never weakens a kernel's hardening and never changes its command line to work around them.
What cairn checks
When the kernel embeds its configuration (CONFIG_IKCONFIG), cairn checks the options above and names each missing or modular one in the error. Without an embedded config it warns and tries the boot. These are compatibility checks, not a boot guarantee: a kernel can still fail in the loader or panic. A failed boot shows the Firecracker error or the guest panic reason in the deploy failure and in cairn status. If cgroup.kill is missing in the guest, exec is disabled for that boot with an explanation on the console; the workload, health checks and event channel keep working. Warnings about a custom kernel appear in deploy.warnings in --json output.
Later boots and stored kernels
The machine's spec records sha256:<digest> and descriptive kernel information. Every later boot verifies the stored file by hash and uses it: restarts, cairn start and starts under systemd. Rebuilding, moving or deleting your source file does not change a deployed machine's kernel. Deploy again to use a new build.
An import of an unchanged file is reused. There is no automatic garbage collection of kernels. Remove a custom file from kernels/custom/ by hand only when no deploy is running and no apps/*/records/*.spec.json names its sha256:<digest>. An import can finish before the machine spec is written, so checking specs alone is not enough during a deploy. If you remove a file a machine needs, its next boot fails with instructions to deploy again.
How it works
The kernels/ directory in $CAIRN_HOME holds:
| Path | Contents |
|---|---|
vmlinux-6.1.155 | the pinned kernel, mode 0444 |
vmlinux-6.1.155.config, manifest.json | facts cairn recorded about the pin |
custom/<sha256> | an imported custom kernel, named by its digest |
verified.json, sources.json | caches that make repeat checks fast |
The caches are a speed-up, not a security check; the files can be re-read and re-hashed at any time. An import reads the source once, hashing, copying and scanning the version banner and embedded config in the same pass, and only publishes the copy after every check passes. Your kernel_file path is opened relative to the project directory without following links that leave it, so it cannot be redirected after the check. The VMM sees the kernel through a read-only mount made by the jail, using the same file descriptor that was verified. See security for the jail.