Skip to main content

Kerf Logo

Kerf: Multikernel Management System

kerf manages multiple Linux kernel instances running side by side on a single host. It carves a pool of CPUs, memory and devices out of the host, hands slices of that pool to spawn kernels, and loads, boots and controls those kernels.

Every resource is described in a device tree that the host kernel holds. kerf validates each change against the full state before it reaches the kernel, so conflicting or invalid allocations are rejected up front.

Contents

Features

  • Resource pool: reserve CPUs, memory and devices for multikernel use, and reshape the pool while it is live
  • Instance lifecycle: create, update and delete kernel instances, each with its own slice of the pool
  • Kernel loading and execution: load a kernel image with an initrd, a Docker image or a rootfs directory, then boot and shut it down
  • Mandatory validation: every operation checks for CPU, memory and device conflicts; validation cannot be skipped
  • Signing and lockdown: sign spawn kernels, and lock them down per run
  • Access to running instances: run commands inside an instance or attach to its console
  • Inspection and replay: show instances, list CPUs, and dump the device tree to replay it later or on another host

Installation

Requirements

  • A host kernel with multikernel support, exposing /sys/fs/multikernel/
  • Python 3.9 or newer
  • musl-gcc when installing from source (e.g. apt install musl-tools), to build the static kerf-init

Python dependencies are installed automatically:

[tool.poetry.dependencies]
python = "^3.9"
pylibfdt = "^1.7.0"      # Device tree parsing (from dtc project)
click = "^8.0.0"         # Command line interface
pyyaml = "^6.0"
pyudev = "^0.24.0"       # Device discovery
cryptography = ">=3.1"   # Signing spawn kernels (kerf sign)
zstandard = ">=0.15"     # Unpacking zstd compressed kernels
lz4 = ">=3.0"            # Unpacking LZ4 compressed kernels

From PyPI

The distribution is named kerf-multikernel; the installed command is still kerf.

pip install kerf-multikernel

# Or isolated with pipx, avoiding conflicts with other packages
pipx install kerf-multikernel

From Source

Recommended for development. Installing builds the static kerf-init, so rerunning pip install after a pull also picks up kerf-init changes.

git clone https://github.com/multikernel/kerf.git
cd kerf

# Installs 'kerf' command to ~/.local/bin/kerf
pip install -e .

# Or install to the system Python's scripts directory
# (typically /usr/local/bin/kerf, or /usr/bin/kerf if using system Python)
sudo pip install .

Check the installation:

kerf --help
kerf init --help

Quick Start

The life of an instance, from an empty host to cleanup:

# 1. Find the physical IDs of the CPUs to hand over
kerf cpus

# 2. Carve a pool out of the host: 7 CPUs (by APIC ID) and 1GB on their NUMA node
sudo kerf init --cpus=128-134 --memory=1GB --report

# 3. Create an instance with a slice of the pool
sudo kerf create web-server --cpus=128-131 --memory=512MB

# 4. Load a kernel image into it
sudo kerf load web-server --kernel=/boot/vmlinuz --initrd=/boot/initrd.img \
               --cmdline="root=/dev/sda1 ro"

# 5. Boot it, then run something inside
sudo kerf start web-server
sudo kerf exec web-server ls /

# 6. Tear it down
sudo kerf kill web-server
sudo kerf unload web-server
sudo kerf delete web-server

# 7. Hand everything back to the host
sudo kerf init --cpus=none --memory=none

Command Guide

Command Purpose
kerf init Initialize or reshape the resource pool
kerf cpus List CPUs with their physical IDs and who holds each
kerf create Create a kernel instance with a resource allocation
kerf update Change the resources of an existing instance
kerf delete Delete a kernel instance
kerf sign Sign a spawn kernel image
kerf load Load a kernel image into an instance
kerf unload Unload the kernel image from an instance
kerf start Boot an instance
kerf kill Shut down a running instance
kerf exec Run a command inside a running instance
kerf console Attach to the console of a running instance
kerf show Show instance information
kerf dump Dump the device tree the kernel holds

Use kerf --help and kerf <command> --help for all options.

Resource Pool

# Initialize resource pool with CPUs and pool memory
# A plain size lands on the NUMA node of the requested CPUs
kerf init --cpus=4-7 --memory=2GB

# Initialize with CPUs, per-node memory and devices
kerf init --cpus=4-31 --memory=8GB@0,8GB@1 --devices=nvme0n1,enp9s0

# Re-run to reshape the live pool; "none" asks for none of a resource
kerf init --cpus=4-15 --memory=4GB
kerf init --cpus=4-15 --memory=none

# Hand everything back to the host
kerf init --cpus=none --memory=none

--cpus takes physical CPU IDs: APIC IDs on x86, MPIDRs on arm64. MPIDRs are written in hex, and --cpus=0x100-0x103 takes the CPUs that exist in that range. kerf cpus lists the IDs and who holds each CPU.

Instances

# Create kernel instance with resource allocation
kerf create web-server --cpus=4-7 --memory=2GB
kerf create database --cpu-count=8 --memory=16GB

# Change what an instance holds
kerf update web-server --cpus=4-9 --memory=4GB

# Delete a kernel instance
kerf delete web-server

Kernel Images

# Load kernel image with initrd and boot parameters
kerf load --kernel=/boot/vmlinuz --initrd=/boot/initrd.img \
          --cmdline="root=/dev/sda1 ro" --id=1

# Sign a spawn kernel where the signing key is kept, not on the host;
# the host kernel must trust the certificate, for example as a MOK
kerf sign /boot/vmlinuz -o vmlinux.signed --key signing_key.pem --cert signing_cert.pem
kerf load --kernel=vmlinux.signed --id=1

# Unload kernel image from an instance
kerf unload web-server

Running Instances

# Boot a kernel instance
kerf start web-server

# Change the entrypoint or add boot parameters for one run, without
# loading the image again
kerf start web-server --entrypoint=/bin/sh --append=loglevel=7

# Run a command inside a running instance (docker exec style)
kerf exec web-server ls /
kerf exec -it web-server sh
kerf exec -u nobody web-server id

# Attach to the console of a running instance
kerf console web-server

# Shutdown a running kernel instance
kerf kill web-server

Lockdown

Lockdown is chosen per run. The next start without the option is not locked down.

# Lock a spawn kernel down at either of the kernel's two levels,
# integrity or confidentiality
kerf start web-server --lockdown=integrity

# Or pick individual confidentiality restrictions on top of integrity
kerf start web-server --lockdown=integrity --deny=kcore,xfrm-secret

--deny restrictions are enforced by kerf-init, and the spawn kernel needs BPF LSM and BTF. For a spawn that boots its own initramfs, kerf-init runs first and root in the spawn is trusted not to lift the restrictions, which only stay pinned in a bpffs.

Inspection

# Show kernel instance information
kerf show
kerf show web-server

# List the CPUs with the physical IDs that --cpus takes, and who holds each
kerf cpus

# Dump the device tree the kernel holds: DTB to replay, --dts to read
kerf dump -o host.dtb
kerf dump web-server -o web.dtb
kerf dump web-server --dts

Reusing a Dumped Baseline

kerf dump writes the device tree the kernel holds, byte for byte, and kerf init --input and kerf create --input accept it back. This is the supported way to capture a configuration and replay it later or on another host; hand-written device tree files are not supported. An instance dump carries its CPUs, memory size, devices and id; --static is given again on the command line.

sudo kerf dump -o host.dtb            # baseline
sudo kerf dump web-server -o web.dtb  # a running instance
sudo kerf init --input=host.dtb       # replay the baseline
sudo kerf create --input=web.dtb      # recreate the instance
sudo kerf dump --dts                  # read it; text is not replayable

How It Works

Design Principles

  1. Single source of truth: the baseline device tree describes the hardware resources available for allocation
  2. Mandatory validation: every operation validates the full configuration
  3. Fail fast: resource conflicts are caught immediately, and invalid output is never produced
  4. Overlay-based management: instance changes are applied as device tree overlays
  5. Developer friendly: clear error messages with suggestions for fixing problems

Baseline and Overlays

The global device tree has two parts:

  1. Resources (/resources): all physical resources in the pool. This is the baseline, written by kerf init. It contains no instances.
  2. Instances (/instances): the resource assignment of each spawn kernel, including its device references. These are added by overlays from kerf create and kerf update.

kerf init builds the baseline from its command line arguments, validates it and writes it to the kernel:

kerf init --cpus=... --memory=... --devices=...
         │
         ▼
    ┌─────────┐
    │ kerf    │ ← Builds and validates
    │  init   │   the resource pool
    └─────────┘
         │
         ▼
    Baseline DTB
    (resources only)
    → /sys/fs/multikernel/device_tree

Instance changes compute the delta between the current state and the modified state, validate the full result, and apply a minimal overlay (DTBO):

Current State (Baseline + Overlays)  +  Requested change
                     │
                     ▼
              ┌─────────────┐
              │ kerf        │ ← Validates full state
              │ (create/    │   before generating overlay
              │  update/    │
              │  delete)    │
              └─────────────┘
                     │
                     ▼
                 DTBO Overlay
    → /sys/fs/multikernel/overlays/new
                     │
                     ▼
              Applied Overlay
    → /sys/fs/multikernel/overlays/tx_XXX/

Each overlay is a transaction. The effective device tree is the baseline plus all applied overlays:

Baseline DTB (static)
         │
         ├─── Overlay tx_101 (instance: web-server)
         ├─── Overlay tx_102 (instance: database)
         └─── Overlay tx_103 (update: web-server resources)
                    │
                    ▼
         Effective Device Tree
    (Baseline + All Applied Overlays)
                    │
                    ▼
         Kernel Instance Views
    /sys/fs/multikernel/instances/*

Kernel Interface

The kernel exposes a filesystem interface, mounted at /sys/fs/multikernel/:

/sys/fs/multikernel/
├── device_tree              # Baseline DTB (resources only, writable via kerf init)
├── overlays/                # Overlay subsystem
│   ├── new                 # Write DTBO here to apply overlay
│   ├── tx_101/             # Applied overlay transaction
│   │   ├── id              # Transaction ID: "101"
│   │   ├── status          # "applied" | "failed" | "removed"
│   │   ├── dtbo            # Original overlay blob (binary)
│   │   └── ...
│   └── tx_102/
│       └── ...
└── instances/              # Runtime kernel instances (read-only)
    ├── web-server/
    │   ├── id              # Instance ID
    │   ├── status          # Instance status
    │   └── ...
    └── ...
  • Rollback: removing an overlay transaction directory (rmdir /sys/fs/multikernel/overlays/tx_XXX/) rolls the change back
  • Kernel generated: instance directories are generated by the kernel from the baseline and the applied overlays
  • Name-based addressing: the instance node name in the device tree (/instances/web-server) is the directory name under instances/. The kernel assigns numeric IDs, but users reference instances by name, so no manual ID coordination is needed

Validation Rules

All kerf operations validate automatically, against the full state (baseline plus all overlays). Validation cannot be disabled or skipped.

CPUs

  1. CPUs must be defined in the baseline resource pool
  2. No CPU can be allocated to multiple instances
  3. CPU lists should be explicitly enumerated

Memory

  1. Memory regions must be within the baseline memory pool
  2. Memory regions cannot overlap between instances
  3. Sum of all allocations must not exceed baseline memory pool size
  4. Memory base addresses must be page-aligned (4KB = 0x1000)

Devices

  1. Referenced devices must be defined in the baseline
  2. Devices can only be allocated to one instance (exclusive access)
  3. Device references must be valid (no dangling phandles)
  4. SR-IOV VF numbers must be within device limits
  5. Namespace IDs must be within device limits

Global

  1. Instance names must be unique
  2. All phandle references must resolve
  3. Baseline resource configuration must be complete and consistent

References

Metadata

Release files for kerf-multikernel 0.6.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for kerf-multikernel 0.6.0
File Size Uploaded Provenance Actions
kerf_multikernel-0.6.0.tar.gz 137.6 kB With provenance Details for kerf_multikernel-0.6.0.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for kerf-multikernel 0.6.0
File Interpreter ABI Platform Actions
kerf_multikernel-0.6.0-py3-none-manylinux2014_x86_64.manylinux_2_17_x86_64.musllinux_1_1_x86_64.whl Python 3 none Linux glibc 2.17+ x86-64, Linux musl 1.1+ x86-64 Details for kerf_multikernel-0.6.0-py3-none-manylinux2014_x86_64.manylinux_2_17_x86_64.musllinux_1_1_x86_64.whl
kerf_multikernel-0.6.0-py3-none-manylinux2014_aarch64.manylinux_2_17_aarch64.musllinux_1_1_aarch64.whl Python 3 none Linux musl 1.1+ ARM64, Linux glibc 2.17+ ARM64 Details for kerf_multikernel-0.6.0-py3-none-manylinux2014_aarch64.manylinux_2_17_aarch64.musllinux_1_1_aarch64.whl

Total release size: 543.6 kB

Release files / kerf_multikernel-0.6.0.tar.gz

Download URL kerf_multikernel-0.6.0.tar.gz
Size 137.6 kB
Tags Source
SHA-256 checksum
How to use checksums
5d47ef1b2e3bf8d48297a52d76be9ff6e512c69a24367b704ce28724e6ff3cb5
BLAKE2b-256 checksum
How to use checksums
d9118d448144737910142ddb11e7c79efef970710e1e8fb653d506583b3c3ba9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 30, 2026.

Transparency log

Release files / kerf_multikernel-0.6.0-py3-none-manylinux2014_x86_64.manylinux_2_17_x86_64.musllinux_1_1_x86_64.whl

Download URL kerf_multikernel-0.6.0-py3-none-manylinux2014_x86_64.manylinux_2_17_x86_64.musllinux_1_1_x86_64.whl
Size 199.1 kB
Tags Linux glibc 2.17+ x86-64 Linux musl 1.1+ x86-64 Python 3
SHA-256 checksum
How to use checksums
918f300858b07fe6de4adef2323c43c76c5a2d0bf2f2e19541f13e073f0a0331
BLAKE2b-256 checksum
How to use checksums
be56cf4801cebeef5fd134b98bc74c60c1eaba90f87c28f4f636c1fae4c4fae8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 30, 2026.

Transparency log

Release files / kerf_multikernel-0.6.0-py3-none-manylinux2014_aarch64.manylinux_2_17_aarch64.musllinux_1_1_aarch64.whl

Download URL kerf_multikernel-0.6.0-py3-none-manylinux2014_aarch64.manylinux_2_17_aarch64.musllinux_1_1_aarch64.whl
Size 207.0 kB
Tags Linux glibc 2.17+ ARM64 Linux musl 1.1+ ARM64 Python 3
SHA-256 checksum
How to use checksums
412f6aa19bb2fbdf46700de89cae1c7bf81cdf8b682f24cb1f41ffc898b460cb
BLAKE2b-256 checksum
How to use checksums
1f8de4287cfd13d8d3cc8ccbe5352dca6c5988234a63a82fba2d391d11a837db
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 30, 2026.

Transparency log

Security for kerf-multikernel 0.6.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 3 files in this release have been uploaded with provenance metadata.

Select from 3 files

Attestation for kerf_multikernel-0.6.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 30, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page