Minimal bootable disk image builder
README.md

uniboot #

Bootable disk images and their signed, updatable boot chain.

A device in the field should boot only bytes that someone signed. It should
still boot after an update is cut off halfway, and nobody should be able to
put an older release back on it, known holes and all. LinuxKit and similar
tools are good at building small, reproducible images, but they stop once
the image exists, and every project ends up adding the signing, the A/B
update and the anti-rollback counter itself.

Uniboot handles the image and what happens to it afterwards. From a kernel,
an initramfs (cpio) and a rootfs (squashfs), given as command-line flags or
in a YAML file, it builds a disk image and writes it raw or as qcow2. Each component can come from a local file, a local directory or an
OCI image reference. An OCI reference is pinned to an immutable content
digest and cached under $XDG_CACHE_HOME/uniboot, so the same inputs give
the same image down to the partition GUIDs. Nothing is random
there: a partition GUID is a version 5 UUID (SHA-1 over a namespace and a
name) of a fixed uniboot URL followed by the partition's index, name, type,
and first and last sectors, and the disk GUID hashes the placements of all
the partitions the same way.

Uniboot then signs those images and updates them over the air. The boot
chain is A/B secure boot over a dm-verity rootfs, with a content-addressed
store and a hardware anti-rollback counter. A separate backend commits
uplink releases to the
store on the device. The boot manifest is a standard SUIT envelope (the
RFC 9019 architecture, the RFC 9124 information model and the
draft-ietf-suit-manifest serialisation). The uniboot.suit sublibrary
encodes it with
ocaml-suit.

Three kinds of target are supported. On UEFI machines (PCs and servers),
the firmware loads a PE executable from the EFI System Partition (ESP), a
FAT partition marked by a fixed GPT type GUID, and uniboot's GPT/UEFI images
carry a real FAT ESP. The executable can be a Unified Kernel Image: a
systemd EFI stub with the kernel, its command line and the initramfs added
as sections, so that secure boot signs and measures a single file. Raspberry
Pi images use MBR, and the board is described by a devicetree, the binary
description of its CPUs, memory and devices that the kernel reads at boot
instead of probing, plus overlays that patch it (to enable an add-on board,
say). The fdt codec checks
the devicetree and its overlays and can merge them ahead of time. Yocto
builds are the third: --yocto-deploy takes the kernel, devicetree, overlay
and rootfs straight from tmp/deploy/images/<machine>.

Contents #

Security #

  • Pinned inputs. An OCI reference is resolved to an immutable digest
    before anything is fetched. A warm cache hit is checked again against
    the content manifest recorded when it was first fetched and verified,
    so a checkout tampered with in the cache (its contents, a file mode or
    a symlink target) is refused and never assembled into a signed image.
    uniboot lint warns about a tag-only reference before any build runs.
  • Verified root. uniboot release measures the squashfs rootfs with
    dm-verity and puts its root hash, and the kernel's own content hash, on
    the UKI command line. An Ed25519 and an ML-DSA-65 signature both cover
    the manifest. The manifest names two objects by content digest: the
    release's runner (the kernel, the initramfs and the rootfs verity root)
    and its application set. Each application in that set carries two
    identities, the digest of the OCI image it was published as and the
    dm-verity root of the blob it runs as. A device loads each object from
    the content store, checks its bytes against the recorded digest and
    lets dm-verity enforce the rootfs and every application blob, so what
    it runs traces back to both keys.
  • Anti-rollback. Each release carries a --release-version. A
    staged release must clear both the disk's root-ref counter and the
    --floor reported by the device's hardware counter. The root-ref
    record on disk stores an anti-rollback floor that advances when a
    release is confirmed; the hardware counter (a TPM NV floor, or a count
    of blown OTP fuse bits) holds the same floor where an attacker who
    rewrites the disk cannot lower it. A release's version must be at least
    both, so a rewritten disk record alone cannot re-admit an old release.
    --rollback names the backend stage 1 enforces it with, and a release
    cannot be built without one. It defaults to tpm, the TPM floor
    behind the seal policy, which only stage 1 raises, to the record's
    floor on every boot, as AVB and MCUboot raise theirs in the bootloader;
    a target with no TPM names file:PATH or popcount:PATH. A counter
    kept where the adversary writes (Rollback.authenticated) is refused
    as none is: writing back its older record with the root-ref's lowers
    it as a disk rewrite does. A popcount: counter reads a range of OTP
    (one-time programmable) fuses, such as the Raspberry Pi customer OTP
    through sysfs, and counts the set bits. A fuse bit goes from 0 to 1 once
    and never back, so the value can only rise. popcount:PATH@FIRST+BYTES
    counts only the words a shared bank gives this counter. file: is a plain
    file counter for development, which a disk rewrite can replay, and a
    UEFI variable is no place for it: root in the booted system writes one.
  • Authenticated boot state. The root-ref record is a small mirrored
    record on its own partition that names which signed release the device
    boots: the confirmed release, a pending release under trial and a
    last-known-good release, each by manifest digest and version, plus the
    trial attempts left and the floor. It is authenticated with
    HMAC-SHA-256 under a 32-byte device key that the platform provisions
    outside the disk: the first boot reads it from the node
    --statekey-path names, an OTP range, or a TPM 2.0 that the key is
    sealed to (uniboot tpm seal). An attacker who can rewrite the disk therefore
    cannot forge a boot selection. Only the TPM keeps the key from the
    booted system: stage 1 unseals it and closes the TPM before the
    hand-over. An OTP range or a key file stays readable by root in the
    booted system, which keeps /dev, /proc and /sys across the
    pivot, so on those sources a compromised release writes records of
    its choosing, and the floor that holds against it is the hardware
    counter's and the command line's alone.
  • Torn-update safety. uniboot update writes the new release into
    the content store and writes a stage intent beside the root-ref record
    naming it. The ESP is written once, at
    build time, and never rewritten, so an interrupted update cannot tear
    the boot loader. The new release is trial-booted for --tries
    attempts. If nothing confirms it, the device rolls back to the
    confirmed release, whose rootfs blob is still in the store. The
    remaining attempts live in the root-ref record. Stage-1, the initramfs
    program that runs before the real root is mounted, verifies the release
    the intent names against the trust anchors and the floor, stages it,
    spends one attempt and writes the record back before it boots the
    pending release, so a crash still counts the attempt. The intent, like
    the health report below, needs no device key: whoever can write the
    disk can at most have the device try a signed release above the floor,
    as ChromeOS firmware honours the GPT tries update_engine sets only for
    a kernel it verifies. A health service in the booted system
    calls confirm, which writes a health report beside the record, and
    the next stage 1 applies it: the pending release becomes the confirmed
    one and the floor advances. The report needs no device key, so it works
    where only stage 1 can unseal the key; with no attempts left, stage-1
    boots the confirmed release instead. A confirmed release that later
    proves unrunnable is reported the same way, with fall_back, and the
    next stage 1 boots the last-known-good in its place once that release
    verifies against the anchors and the floor.
  • Signed configuration. Payload boot arguments go in through
    --append and are baked into the signed UKI command line. Runtime
    configuration therefore has the same integrity as the image, and
    nobody who controls a side channel can steer a verified boot. A release
    naming a SUIT vendor and class bakes their 32 bytes beside the trust
    anchors in the signed initramfs; stage 1 refuses a manifest for another
    class even when both release signatures verify.
  • TPM-held state stays with stage 1. Where the root-ref key and the
    anti-rollback floor live in a TPM, the key is sealed under a signed
    PCR policy and the floor is written only through it: the TPM
    releases both only to a boot whose PCRs hold a state a release signer
    approved (uniboot tpm seal, uniboot tpm approve:
    TPM2_PolicyAuthorize over TPM2_PolicyPCR, PCRs 11 and 12 by
    default, the approval shipped inside the stage-1 UKI). Stage
    1 unseals the key, then extends a barrier PCR and only then kexecs into
    the selected release or pivots into its root, so neither the release's
    own init nor its system can unseal the key or move the floor again.
    The window that remains is stage 1 itself. An approval does not
    expire, so one for an older, flawed stage 1 stays good until the seal
    is redone without its signer. Provisioning (uniboot tpm provision)
    ends by making that policy the owner hierarchy's only authorization,
    with clearing disabled, so no process can delete the floor and
    define it again, or seal a key of its own where stage 1 would load it.

The tool has limits. uniboot inspect has no device key, so it prints
what a root-ref record claims without checking its MAC. Raspberry Pi secure boot is whatever the
firmware implements: an RSA-2048 signature over a boot.img ramdisk,
verified against the customer key hash fused into OTP. uniboot push scaleway imports an x86_64 image as a local-storage snapshot of the
kind --volume-type names (l_ssd by default, and the only kind that
import path accepts), so such an image needs an instance type with local
storage. An arm64 root snapshot goes through the Block Storage API
instead, which has no volume type to choose. uniboot run is a smoke
test: the server or virtual machine it creates is destroyed when the
command exits.

Who owns what #

A fleet is run with three tools, and each is responsible for one part:

  • uniboot owns the image. It builds images and owns their layout,
    their slots and the content store. It is the only tool that writes
    image bytes to a medium, whether it publishes to a cloud, flashes a
    bench device or runs an image once locally.
  • uplink owns the
    movement of trust.
    It packages, signs, verifies and delivers
    releases, and it owns anti-rollback and the confirmation step.
  • caravan owns the
    intent.
    It declares which target should run which release, plans the
    change, converges on it, and refuses what it cannot do. It never builds
    or signs anything and never reads image bytes.

The three tools name a release by the same digest. Uniboot computes it
when it builds the release, uplink carries it, caravan checks it, and the
device reports it back.

Installation #

Install with opam:

$ opam install uniboot

If opam cannot find the package, it may not yet be released in the public
opam-repository. Add the overlay repository, then install it:

$ opam repo add samoht https://tangled.org/gazagnaire.org/opam-overlay.git
$ opam update
$ opam install uniboot

Uniboot requires OCaml 5.1 or later.

Usage #

$ uniboot build -o disk.img \
>   --kernel docker.io/library/kernel:6.9 \
>   --rootfs /path/to/rootfs/

uniboot build --help lists the component, partition-size and platform
flags. --image-format raw|qcow2 picks the encoding, defaulting to the
one the output extension names. --virtual-size MB sets a minimum disk
size for import APIs that demand one. A build publishes atomically: the
image is fsynced, renamed over the output path, and the parent directory
is synced. Every filesystem failure the build can meet comes back as an
error naming the path, never as an exception.

Commands #

Command What it does
app Convert a local OCI layout into a verified application blob and JSON metadata.
host Apply signed releases with public keys bound to their queues and map verified blobs.
inventory Inspect exact live environment image and verity identities, or print their JSON for a probe.
served Print the version and keys of the release a queue serves, or their JSON for a probe.
build Build a disk image from component flags or --config.
guest Build the guest image buildr build --runtime vm boots into a content-addressed store.
rpi Build a Raspberry Pi image, optionally signed for secure boot.
jetson Report the files uniboot resolves from a Jetson Linux (L4T) tree.
lint Check YAML build configurations without fetching or building.
inspect Print a disk image's partitions and their contents.
release Build a signed release, optionally as a bootable disk image.
update Stage a new signed release onto a live disk.
update-apps Stage an application-only update onto a live disk.
push scaleway Publish a qcow2 image to Scaleway and print its image ID, or with --data a data snapshot and print the snapshot ID.
run scaleway | run vz Boot a published or local image, attach extra volumes, and watch its console.
flash Write a released image to a bench device.
tpm seal | tpm approve | tpm provision Seal the root-ref key under a signed PCR policy, embed in a stage-1 UKI the approval of the PCR 11 it boots with, and define the floor and lock the owner hierarchy under the policy.

Standalone application blobs #

uniboot app --layout image.oci --scratch image-store/scratch -o tool.blob
verifies the local OCI image layout and writes one deterministic squashfs
followed by its dm-verity tree. --platform linux/amd64 selects an index's
platform; --id-offset UID assigns the filesystem's rootless host owner.
Standard output is JSON with oci, root, digest and size: the OCI index
identity, verity root, SHA-256 of the entire file and its byte length. A signing
machine can name the artifact from that metadata while the image bytes stay
on the build host. Scratch belongs on the image store's volume and private
extraction directories are removed on every exit. A failed conversion leaves
an existing output intact.

uniboot app --component NAME emits the shared release image metadata
(name, whole-file SHA-256 digest, and byte size) for uplink sign.
The queue can sign that metadata without opening the blob. The optional
component name follows the release descriptor's safe-name contract.

The builder VM's guest #

uniboot guest builds the Linux guest that buildr build --runtime vm
boots, the builder VM of the package builder-vm. It writes a directory
holding a bare kernel Image, an initramfs and a manifest.json that pins
the platform and the SHA-256 of both boot files. The guest's name is the
SHA-256 of that manifest:

$ uniboot guest --platform linux/arm64 \
>   --kernel kernel/Image --kernel-digest sha256:KERNEL_DIGEST \
>   --init builder-vm-init --buildr buildr --runc runc \
>   --rootfs support-rootfs --store /srv/guests
sha256:NAME /srv/guests/NAME

The kernel is the /kernel of the builder kernel this repository's recipe
builds (make build EXTRA=-builder under kernel/), and --kernel-digest
is the SHA-256 of that exact object, checked before it is decoded. An arm64
gzip Image or EFI zboot object is decoded to the bare Image
Virtualization.framework loads, and the manifest pins the decoded bytes, so
equivalent kernel formats give one guest; linux/amd64 takes a 64-bit
bzImage. --init, --buildr and --runc must be static ELF executables of
the platform: one with an interpreter or a DT_NEEDED library is refused.
The buildr package's guest-static profile links its two. The optional
--rootfs tree, the OS trust roots and the helpers the guest's buildr runs,
is packed first, and the three executables override any file of the same
name in it. The archive records no host path, owner or timestamp, so one set
of inputs gives one name.

The store is content-addressed and immutable once made: the guest is packed
in a staging directory of the store, its files are made read-only and it is
renamed to STORE/HEX, the name's hex digits. A name the store already holds
is verified and kept as it is, never rewritten. A failed build leaves the
store as it was. Without --store, the store is guests under uniboot's
cache directory. The directory is what BUILDR_VM_GUEST selects, and the
name is what buildr guest verify --digest checks before a boot:

$ buildr guest verify --digest sha256:NAME /srv/guests/NAME
$ BUILDR_VM_GUEST=/srv/guests/NAME buildr build --runtime vm \
>   --platform linux/arm64 --output type=local,dest=out .

Matching names from two producers show that the assembly is reproducible.
They do not show that the compiler or the kernel producer is.

Host application releases #

The pure uniboot.host-config library owns public environment trust:
validated vendor UUIDs, queue-scoped anchors and the signature allowlist.
Host definitions and uniboot host consume that declaration without giving
an image builder or worker access to private signing material.

uniboot host --dir environments --key queue=queue-public.pem --vendor-id UUID
applies that queue's signed release and maps its blobs read-only. Repeat
--key QUEUE=FILE for each queue and for each key admitted during rotation.
--algorithm ALG is repeatable and defaults to ed25519; only the selected
signature algorithms are admitted. A public key grants authority only to its named queue; a queue with no key
binding is refused before any blob is ingested. The vendor UUID and the queue
name determine the expected class identity, and the queue's published version
is its anti-rollback floor. The host holds public keys only; the queue's
machine holds its signing credential.

An environment input key is a Git tree identifier or SHA-256, 40 or 64
lowercase hexadecimal digits. Each mapping records its authenticated blob
digest, byte length and actual verity root under the reader lease. A
replacement under one input key waits for old readers before remapping.
Two queues naming different images for one key advertise neither image.

uniboot inventory --dir environments inspects the live device and mount,
not just its persistent lock. --json emits the bounded
uniboot.host-inventory codec for a probe. An absent mount, incomplete
mapping, conflicting claim or replacement waiting for readers is omitted.
The observed verity root describes the host's bytes; it does not change
the input key. Inspection reads no signing key and changes no state.

uniboot served --dir environments --queue QUEUE prints the release
QUEUE serves: its version, the counter the queue raises at each
release, and each key it holds by its blob's digest and size, whether
mapped yet or not. --json emits uplink's descriptor codec, or null
when the queue serves no release. It takes no lock and changes no state.
Blob collection requires a readable retained-release set and every retained
descriptor. An unread set or descriptor fails the pass before any blob is
collected.

Declarative builds #

uniboot build --config builds the image a YAML file describes. A layout
too rich for the component flags, such as a Unified Kernel Image
assembled from an OCI kernel and rootfs, is then written down as data:

platform: linux/arm64

kernel:
  image: linuxkit/kernel@sha256:9b6408...

uki:
  cmdline: console=hvc0 ip=dhcp

initramfs:
  base:
    - image: networkstatic/iperf3@sha256:aaa9...
      subdir: rootfs
  files:
    - {path: init, contents: "#!/bin/sh\n/usr/bin/iperf3 -s\n", mode: "0755"}
    - {path: dev, directory: true}
    - {path: dev/console, device: {kind: char, major: 5, minor: 1}}
  gzip: true

partitions:
  - esp: {size-mb: 64}

A uki section wraps the kernel in a Unified Kernel Image over an EFI
stub (systemd's linuxx64.efi.stub or linuxaa64.efi.stub). The kernel,
the cmdline and the initramfs become the .linux, .cmdline and
.initrd PE sections, so the firmware boots one file, and secure boot
signs and measures that one file. Unknown keys are rejected, YAML anchors
let one inline value serve several targets, and relative paths resolve
against the directory of the configuration file. Uniboot.Spec is the
schema reference, and examples/ holds complete
configurations.

A program gives a Uniboot.config directly and reads no file.
Uniboot_cli.image (library uniboot.cli) is the command image over
that value, for an operator's executable that is a cmdliner group of its
own declarations:

let push =
  Uniboot_cli.scaleway ~bucket:"example-images"
    ~arch:Scaleway.Instance.Image.Arm64 ()

let ops config =
  Cmdliner.Cmd.group
    (Cmdliner.Cmd.info "example-ops")
    (Uniboot_cli.image ~push ~virtual_size_mb:1024 ~name:"example" config)

image build -o DIR writes DIR/example.qcow2 and its raw disk
DIR/example.img, and prints the reference a caravan target names the
image by, example-<12 hex>@sha256:<64 hex>: the qcow2's SHA-256, whose
first 48 bits complete the name. uniboot build --config writes the same
qcow2 from a YAML document that decodes to the same configuration.
image push DIR publishes DIR/example.qcow2 as uniboot push scaleway
does, under the reference's name.

uniboot lint CONFIG... decodes each configuration against that schema
and checks what it points at without fetching anything. A missing local
source, a local source of the wrong kind and an invalid OCI reference are
errors; a tag-only reference is a warning.

Raspberry Pi images #

uniboot rpi builds an image that the Raspberry Pi firmware boots
directly. The image has an MBR partition table, a FAT boot partition and
a read-only squashfs root partition. The boot partition holds
config.txt, cmdline.txt, the kernel, the board devicetree and its
overlays. The devicetree and overlays are decoded before they are
placed, so a corrupt or wrong file fails the build instead of the boot.

$ uniboot rpi -o cm5.img \
>   --yocto-deploy tmp/deploy/images/raspberrypi5 \
>   --dtb bcm2712-rpi-cm5-cm5io --sign-key secure-boot.pem --secure

With --sign-key, the boot partition tree is packed into a boot.img
ramdisk and signed into a boot.sig that is byte-compatible with
rpi-eeprom-digest. These are the ramdisk and the RSA-2048 signature
that the Raspberry Pi secure-boot firmware verifies against the customer
key hash fused into OTP. Without --secure, the pair is written beside
the disk for a provisioning step to place. With --secure, the boot
partition uses the two-level layout the firmware boots directly: an
outer FAT with boot_ramdisk=1, the signed boot.img and boot.sig,
and the real boot tree inside the signed image. Set SOURCE_DATE_EPOCH
to stamp a reproducible timestamp into the signature.

Signed releases and over-the-air updates #

uniboot release builds the secure boot chain. It produces three
things: a Unified Kernel Image whose command line carries the dm-verity
root of the squashfs rootfs, a manifest signed under two keys, and the
initial boot-state record. The manifest names the release's runner (the
kernel, initramfs and rootfs verity root) and its application set, each
by content digest, under an anti-rollback version.

Each --app takes [NAME=]REF. The reference is pinned to its sha256
digest, verified and turned into a dm-verity squashfs blob. The
application set lists it under NAME, or under the image repository's
basename when the prefix is omitted, with both identities: the pinned
OCI digest and the blob's verity root. One manifest therefore covers the
base system and the application set together.

With --image, the release is also assembled into one bootable GPT
disk. The stage-1 UKI sits on the ESP, the mirrored boot-state store has
its own typed partition, and the content store holds the signed manifest
(keyed by its content identity) beside the verity rootfs.

$ uniboot release -o out/ --image disk.img \
>   --stub linuxx64.efi.stub --kernel vmlinuz --rootfs rootfs/ \
>   --app registry.example/sensor@sha256:9f86d081... \
>   --ed25519-key ed25519.seed --mldsa65-key mldsa65.seed \
>   --state-key device.key --release-version 3

$ uniboot update --disk disk.img \
>   --stub linuxx64.efi.stub --kernel vmlinuz --rootfs rootfs/ \
>   --ed25519-key ed25519.seed --mldsa65-key mldsa65.seed \
>   --release-version 4 --tries 3

--ed25519-key and --mldsa65-key are the 32-byte seeds the manifest is
signed under. A release carries a signature from each, and a device
verifies both. --state-key is the 32-byte device key that authenticates
the boot-state record release writes; update writes a stage intent
and no record, so it takes no key. Each key is read as raw bytes.

A FIPS 140-3 validated HSM implements ML-DSA (CMVP certificate 5497;
Thales Luna T7 under certificate 5450), so the ML-DSA-65 seed is held in
that module, not on the build host; the Ed25519 seed can live on a
PKCS#11 token. PKCS#11 v3.2 defines CKM_ML_DSA and v3.1 CKM_HSS, and
NIST SP 800-208 puts the HSS state in the module for flight. uniboot release -o writes uki.efi, manifest.signed and root-ref into the
output directory.

Two runs over the same inputs write the same release, byte for byte, and
no flag is needed for that. The manifest's ML-DSA-65 signature uses the
deterministic variant of FIPS 204, and every other byte of a release is
derived from the parts it was assembled from.

--carry-kernel stores the kernel and initramfs in the content store as
flat blobs, as well as naming them in the manifest. A device whose
running kernel is not this release's kernel can then load, verify and
kexec into the carried one. (kexec loads a new kernel and jumps
to it from the running one, without going back through the firmware.)
Without --carry-kernel, the device can boot the release
only when its running kernel is already the right one.

The remaining flags stamp values into the signed command line or shape
the --image disk:

  • --append ARGS adds payload boot arguments.
  • --rollback tpm, tpm:INDEX, file:PATH or popcount:PATH names
    the hardware counter stage 1 enforces the floor with; tpm is the
    default, and there is no none and no authenticated:PATH.
  • --statekey-path PATH names the OTP or TPM node the first boot reads
    its MAC key from.
  • --esp-size MB, --state-slots N, --data-mb MB and --virtual-size MB size the ESP, the number of mirrored record copies, a raw data
    partition the booted system formats and mounts, and the whole disk.
  • --refresh resolves an OCI tag to a fresh digest instead of reusing
    the locked pin.

update and update-apps also take --floor VERSION, the device's own
anti-rollback floor. A release that the real stage-1 would refuse is
then refused at staging time, even on a disk whose record an attacker
may have rewritten.

uniboot update stages a new release onto a live disk. It appends the
new rootfs blob to the content store and keeps the running version's
blob as a rollback target. It appends the new manifest as a content-store
blob keyed by its identity, then stages the boot-state record so that
the next boot tries the new release. The disk is opened once, and that
open takes the exclusive device lock. The offsets parsed from the disk
and the writes that use them go through the same descriptor, so no
concurrent updater or on-device confirmation can slip in between the
reads and the writes. The device trial-boots the release for --tries
attempts. A userspace health service confirms it, or the device rolls
back to the confirmed release.

uniboot update-apps stages an application set on its own. It reuses
the confirmed release's runner (the kernel, initramfs and rootfs,
unchanged) and appends only the new application set and the new
applications' OCI blobs, so shipping an application does not rebuild a
rootfs.

Publishing and booting #

uniboot push scaleway publishes a qcow2 release to Scaleway. It stages
the image in an Object Storage bucket, imports it as a snapshot,
registers a bootable image from that snapshot and prints the image ID.
The source file is opened once, and that descriptor supplies everything
the push reads: the disk size, the digest, the object length and the
uploaded bytes. A file replaced underneath the push therefore cannot
make the staged image differ from the registered one. The full SHA-256
is attached to the snapshot and the image as a tag. Pushing the same
file twice finds the first upload and sends nothing. A name that already
carries a different digest is an error that names both digests; the
push neither reuses nor overwrites it.
The Scaleway profile's default project is the import target. The staged
Object Storage requests sign with its access key qualified by that project
([ACCESS_KEY@PROJECT_ID]), so one profile selects both the bucket and the
snapshot's project. A profile without a default project cannot stage an
upload.

$ uniboot release -o out/ --image disk.qcow2 --virtual-size 1024 \
>   --stub linuxx64.efi.stub --kernel vmlinuz --rootfs rootfs/ \
>   --ed25519-key ed25519.seed --mldsa65-key mldsa65.seed \
>   --state-key device.key

$ uniboot push scaleway disk.qcow2 --bucket my-bucket --arch arm64
$ uniboot run scaleway <the image id that printed> -p 8080:80

push scaleway --data publishes the same file as a Block Storage
snapshot instead of a bootable image. There is no registration and no
architecture, only bytes, and the command prints the snapshot ID. run scaleway --volume NAME:snapshot:ID consumes it: the server boots with
that snapshot attached as an extra volume, which is the next disk the
guest sees. --volume NAME:SIZE creates a blank volume of SIZE GB
instead, for a guest that formats its own.

run scaleway sizes and places the server with --type, --zone,
--profile and --name, and requests routed IPv6 with --ipv6. Each
-p HOST:GUEST opens that guest port in a security group created for
the run. --from auto|any|CIDR says who may connect; auto, the
default, discovers the caller's own address and admits only that.
--security-group ID hands the server an existing group instead, whose
rules the caller owns.

By default the command watches the console until it is interrupted, then
tears the server down. --watch SECONDS detaches after that many
seconds, --no-console skips the console entirely and --no-clean
leaves the server running. The teardown runs even when the boot fails,
since that is the case that would otherwise leave a paid machine
running. A single --timeout SECONDS (300 by default) bounds every wait
in the session: the server reaching the running state, the server and
its volumes being deleted, and the retried deletion of the security
group that -p created.

uniboot run vz IMAGE boots a raw released image on the local machine
through the vz launcher (macOS Virtualization.framework) and prints the
serial console. Booting spends a trial boot and writes the root-ref
store, so pass --ephemeral to boot a throwaway copy and keep the image
as released. --cpus and --memory size the guest, --watch SECONDS
stops the machine after that many seconds, and -p HOST:GUEST and
--dns ADDR configure the slirp gateway. --disk attaches an extra
volume, in flag order: PATH[:ro] for a raw image, and tar:DIR or
fat:DIR to pack a host directory as a read-only tar image or a
read-write FAT image for the guest to mount. The guest gets a fresh EFI
variable store that is discarded on exit, as a release image gets on a
cloud; --efi-store PATH keeps one across runs.

Inspecting and flashing #

uniboot inspect disk.img reads a raw or qcow2 image and prints the
partition table. For each partition it prints what it can identify by
magic bytes, such as the entries of a cpio initramfs, the blobs of a
content store or the claims of a root-ref record. --cat PATH prints the
bytes of one file instead, so reading a configuration out of an image
needs neither cpio nor a mount.

uniboot flash IMAGE --device DEV writes a released image to a bench
device. A device that already carries the layout keeps its state
partition.

TPM-held state #

A device with a TPM keeps its root-ref key there. uniboot tpm seal
seals the key --state-key FILE holds under a policy: --signer names
each ECDSA P-256 public key (PEM, up to eight) whose approvals release
it. The PCRs that name the boot are fixed: PCR 11, which systemd-stub
extends with the stage-1 UKI's own sections before the kernel runs, and
PCR 12, where it measures a command line the loader passed in place of
the UKI's own, which it honours with Secure Boot off. Every approval
also names PCR 8, the barrier stage 1 extends before it hands over.
--tpm DEVICE reaches a device's TPM and --tpm-socket PATH a VM's
swtpm from its host.

$ uniboot tpm seal --tpm-socket swtpm.sock --signer policy.pub \
> --state-key state.key -o tpmseal
$ uniboot release --tpm-approval-key policy.pem ... --image release.img

PCR 11 depends on the UKI alone, so uniboot release --tpm-approval-key
predicts it when it builds the stage-1 UKI, signs the
TPM2_PolicyPCR digest of PCR 11 at that value and PCRs 8 and 12 at
reset, in each PCR bank, and embeds the approvals as the UKI's
.pcrsig section in systemd's signed PCR policy format (as ukify --pcr-private-key does). uniboot tpm approve --key policy.pem UKI -o OUT does the same to a UKI built elsewhere. systemd-stub hands the
section to stage 1 as /.extra/tpm2-pcr-signature.json, so the
approval ships inside the image it approves: no approval file to
provision, and no firmware measurement, so neither a firmware update
nor a boot application firmware starts before the UKI changes what it
names. A new stage-1 build carries its own approval and the same blob
unseals. With Secure Boot off, code firmware starts before the UKI can
extend PCR 11 to the approved value, so the firmware's Secure Boot db
is what makes the approval name a boot. With uniboot.statekey=tpm,
stage 1 reads the blob from uniboot.tpmseal= and the approvals from
/.extra, talks to the TPM uniboot.tpm= names (/dev/tpmrm0 by
default; a path that names nothing halts the boot) and unseals once.
The blob records the Name of the storage primary it was sealed under,
and stage 1 and uniboot tpm provision refuse a TPM that answers with
another before any session is salted to it.
It opens every TPM the kernel lists and extends the barrier on each
before it hands over, whether it returns, fails or raises, whatever its
command line names, so neither a release it kexecs into nor the booted
system can unseal the key again; the release init it kexecs into
refuses to resume on a boot whose barrier is at reset.

uniboot tpm provision --for tpmseal comes last. It defines the
anti-rollback floor, an 8-byte NV index only the seal policy writes,
which stage 1 writes whole with the record's floor, at --floor-index
(the index uniboot.rollback=tpm reads by default). It then locks the
owner hierarchy, each step checked against the TPM's authenticated
answer: the blob's policy becomes its
only authorization, its authorization value and the lockout's become
random values nobody keeps, and TPM2_Clear is disabled. After it only
stage 1, in a boot the policy approves, can define or delete an NV
index or create the storage primary, and stage 1 does neither, so
sealing again, or a new signer list, means a clear through the platform
hierarchy (a firmware TPM-clear request), which also discards the
sealed key and the floor, then provisioning again. The lock takes the
owner hierarchy from the booted system for good: no storage key of its
own (an SRK), so no systemd-cryptenroll, systemd-creds or clevis
TPM binding, and, with the lockout value gone, no reset of the
dictionary-attack counter.

Committing an OTA release #

uniboot.uplink is a separate library. It implements the TARGET
signature of uplink and
commits a verified over-the-air release to a block device. Uniboot is the
backend and uplink drives the commit. Neither of them carries the
transport that brought the bundle. Only this sublibrary depends on uplink, so
the core uniboot library and its boot chain do not.

A boot slot holds one 32-byte digest, and an uplink release is a set of
named images. They match because a release's content address is the
SHA-256 of its descriptor: the encoded SUIT manifest of the release, the
bytes the envelope's authentication wrapper signs, which lists each named
image with its digest and size. Its SHA-256 is the same release identity
uplink calls the release id. commit stores the descriptor as a
content-store blob keyed by that digest and stages the digest into the
inactive slot, so reading the slot back recovers the whole release. An
update writes one slot pointer and copies no image twice. gc follows each retained slot's descriptor to the blobs it
references and collects the rest. If the blobs behind a slot pointer were
collected, the device would fail to boot at its next rollback.

A commit is a trial. The device keeps it only after the system it
booted reports healthy through confirm. Until then, a device that fails
to boot falls back to the release in the other slot. The signed
Manifest, the dm-verity roots and the boot chain do not change: the
device still boots them and still checks what it boots through them.

API #

The umbrella module of the uniboot library is
Uniboot. Its modules fall into four groups.

Building an image. config, build and build_file assemble an
image from a partition list, whose element is Partition. Spec and
config_of_spec are the declarative YAML schema and its resolution.
Source resolves a component to a local path or a pinned OCI digest.
File, Fat_image, Ext4_image and build_squashfs are the filesystem
writers underneath, and partition_content_digests reports what a built
partition commits to.

Building a signed release. release_spec takes the parameters once,
build_release assembles them and release_image writes the result as
one bootable GPT disk; release_apps_only builds an application-only
release. Runner, App_set and Layer_set are the three
content-addressed objects a release is made of, and Manifest is the
dual-signed envelope that names the first two. App turns an OCI
application into the dm-verity blob it runs as. Rootfs_verity, Uki
and Uefi handle the rootfs encoding, the Unified Kernel Image and the
ESP layout. Payload reads the payload a release launches off the OCI
image it travels in: exactly one uncompressed layer
(application/vnd.oci.image.layer.v1.tar) whose digest is the SHA-256
the signed SUIT manifest names, so the launcher hands over the bytes it
verified and runs no decompressor on them.

Booting and updating a device. Root_ref is the authenticated
on-disk boot record, Selector the I/O-free transaction over it, Boot
the boot manager over an abstract device and Boot_disk that device
over a real GPT disk. Boot_disk is also where stage_release,
install_release and gc live. Content_store is the blob store they
read and append to. Statekey is the device key, Bootargs is the
signed command line, and Ab
is the gptprio staging logic used by the Raspberry Pi tryboot path.
gptprio is the ChromeOS scheme that stores a priority, a tries-remaining
count and a successful flag in the attribute bits of each GPT partition
entry, and boots the highest-priority partition with tries left; tryboot is
the Raspberry Pi firmware flag that boots an alternate configuration once,
falling back to the normal one on the next reset.

Targets and tools. Rpi, Jetson and Yocto read the per-board
file trees. Flash writes a release to a bench device and Inspect
reads one back. Disk and Image are the raw and file-backed byte
layers, and Bootlog measures kernel boot timing.

Each sublibrary is separate, so a program links only the ones it uses:

Library Interface
uniboot.suit lib/suit/uniboot_suit.mli: the boot manifest as a SUIT envelope.
uniboot.uplink lib/uplink/uniboot_uplink.mli: an Uplink.TARGET over the A/B slots and the store.
uniboot.scaleway lib/scaleway/uniboot_scaleway.mli: publishing, booting and the serial console.
uniboot.cli lib/cli/uniboot_cli.mli: the image build and image push commands over a Uniboot.config value, for a site's operator executable; uniboot push scaleway runs the same push.
uniboot.guest lib/guest/uniboot_guest.mli: the builder VM's guest image, its content-addressed store and its verification.
uniboot.vz lib/vz/uniboot_vz.mli: booting a released image locally under the vz launcher.
uniboot.cloud lib/cloud/uniboot_cloud.mli: the pieces of a cloud guest's init: the resolver, the data volume, the user data, and Follow, which keeps the server on the release the user data names.
uniboot.cloud.service lib/cloud/service/uniboot_cloud_service.mli: a service's declaration and its supervision.
uniboot.cloud.init lib/cloud/init/uniboot_cloud_init.mli: a cloud guest's PID 1 for a list of services: the boot steps as values, the secrets read at each start, and the supervision.
uniboot.network lib/network/uniboot_network.mli: what a host image's init writes to bring its network up, decided with no I/O: the rtnetlink requests (RFC 3549) a DHCP lease's state asks for (RFC 2131), the uplink tap, and the stub resolver's configuration.
uniboot.network.eio lib/network/eio/uniboot_network_eio.mli: that step carried out on Linux: the link and the tap over nox-netlink and tuntap, the lease kept with dhcp-eio, and a stub resolver on 127.0.0.53 served with nox-dns-eio.
uniboot.init lib/init/boot_init.mli: the decisions stage-1 makes before it pivots, used to build the uniboot-init binary.
uniboot.host-config lib/host_config/uniboot_host_config.mli: validated public trust shared by host definitions and the environment host.
uniboot.host-inventory lib/host_inventory/uniboot_host_inventory.mli: canonical input keys and exact mapped-image transfer metadata.
uniboot.host lib/host/uniboot_host.mli: authenticated per-queue environment releases and read-only mappings.
uniboot.activate lib/activate/boot_activate.mli: mapping the rootfs layers and stacking them into a mounted root.
uniboot.rollback lib/rollback/rollback.mli: the hardware monotonic counter, with file: and popcount: backends.
uniboot.rollback-tpm lib/rollback-tpm/rollback_tpm.mli: that floor in a TPM 2.0 NV index, the signed PCR policy and approvals that guard it, and the seal, unseal and barrier of the root-ref key.
uniboot.rollback-unix lib/rollback-unix/rollback_unix.mli: the host lock that writers of a file-backed counter share, a record lock on a file beside the counter.

| uniboot.dice | lib/dice/uniboot_dice.mli: DICE layer 0 over a device key the firmware holds, such as the CM5's OTP key: the UDS, the lock that keeps later stages from it, and the next stage's handover. |

Documentation #

  • LinuxKit builds minimal,
    immutable Linux images from OCI components; uniboot borrows its
    workflow.
  • MirageOS is a library operating system for
    building unikernels in OCaml.
  • Solo5 is a sandboxed execution
    environment for unikernels.

Licence #

ISC License. See LICENSE.md for details.