Skip to content

About

Hardware inspection RAM OS for Beskar7 Infrastructure Provider

Resources

Stars

0 stars

Watchers

0 watching

Forks

 
 

Repository files navigation

beskar7-inspector

The hardware-inspection and provisioning ramdisk for Beskar7, a Cluster API infrastructure provider for bare-metal hosts.

The inspector is a single static Rust binary (x86_64-unknown-linux-musl) used directly as the initramfs /init. It PXE-boots on a target machine, probes its hardware natively, reports to the Beskar7 controller, then writes the target OS image to disk and reboots into it. There is no shell, no busybox, and no external tools — every probe and provisioning syscall is performed in-process.

Install (operators)

You do not need to build this. Each release publishes the two boot files your boot server serves, plus their checksums:

REL=https://github.com/projectbeskar/beskar7-inspector/releases/latest/download
curl -fsSLO $REL/vmlinuz
curl -fsSLO $REL/initrd.img
curl -fsSLO $REL/sha256sums.txt
sha256sum -c sha256sums.txt --ignore-missing

These artifacts boot your hardware, so verify them before serving. Releases are signed with cosign keyless signing (no long-lived key):

IDENTITY='^https://github.com/projectbeskar/beskar7-inspector/\.github/workflows/release\.yml@refs/tags/.*$'
ISSUER=https://token.actions.githubusercontent.com

curl -fsSLO $REL/sha256sums.txt.cosign.bundle
cosign verify-blob --bundle sha256sums.txt.cosign.bundle \
  --certificate-identity-regexp "$IDENTITY" --certificate-oidc-issuer "$ISSUER" \
  sha256sums.txt

A failed verification means the artifacts were not produced by this project's release workflow — do not boot them.

Serve both files from one directory and point Beskar7Machine.spec.inspectionImageURL at that directory — the controller appends /vmlinuz and /initrd.img when it renders the per-host iPXE script.

Matching the inspector to your controller

The controller and inspector share a versioned wire contract. A controller speaking contract vN requires an inspector implementing vN. Every release states its contract version, ships it as contract-version.txt, and tags its container image accordingly — so you can pull the right one without guessing:

# the contract version your controller speaks: test/contract/VERSION in the beskar7 repo
docker pull ghcr.io/projectbeskar/beskar7-inspector:contract-v4.2

The image carries both files at /vmlinuz and /initrd.img (convenient for air-gapped mirrors):

cid=$(docker create ghcr.io/projectbeskar/beskar7-inspector:contract-v4.2)
docker cp $cid:/vmlinuz . && docker cp $cid:/initrd.img . && docker rm $cid

Building from source is still supported — see Build, test, lint.

How it works (contract v4.4)

Beskar7 renders a per-host iPXE script that boots this image with the beskar7.* parameters on the kernel cmdline. The inspector then runs two phases:

  1. Enroll & inspect (always) — parse the cmdline, probe hardware from firmware truth (SMBIOS/DMI via /sys/firmware/dmi/tables, plus /sys and /proc), select a target disk, and POST the report to the controller over verified TLS (success is 202 Accepted). --dry-run stops here.

  2. Provision (when bootstrap data is ready) — GET the CAPI bootstrap user-data and the host's network data (if any; a 409 refusal fails the host before the disk is touched), stream the digest-pinned whole-disk OS image (a Kairos raw image) onto the selected disk while verifying its SHA-256, register a UEFI boot entry for the image's ESP loader, inject a per-host cloud-config (carrying the join secret), the provider-id and the network data into the image's COS_OEM partition, and reboot(2) into the provisioned OS.

    The boot entry starts the removable-media loader for the inspector's architecture, \EFI\BOOT\BOOTX64.EFI on x86_64 and \EFI\BOOT\BOOTAA64.EFI on aarch64; an image whose ESP lacks it fails the deploy. An existing entry that already starts that loader on that partition is reused; otherwise the previous beskar7 entry is overwritten, or a new one created. It goes in BootOrder right after the network entries that lead it (counting only entries the firmware boots on its own), or first when the boot order doesn't start with network. A firmware that refuses the NVRAM write (boot order locked in setup, NVRAM full) is logged and left to find the loader itself; legacy BIOS boots and images without an ESP skip the step. Another disk carrying a partition with the same GUID is logged, since the firmware may boot either.

    Some AMI Aptio versions rebuild BootOrder at every POST and drop that entry; with their built-in EFI Shell first, every boot ends in the Shell. For that case, when the image has no startup.nsh of its own, the inspector also writes a random per-deploy marker \EFI\beskar7\<random>.id and a startup.nsh at the ESP root — both or neither. The script looks for the marker on FS0:–FS31: and starts the loader there, or says no disk matched and stops at the Shell prompt. An image's own startup.nsh (at the root, in \EFI\BOOT\ or in \EFI\tools\, where the Shell looks) is left in place, and that is logged; one of ours from an earlier deploy (an image captured from a provisioned disk) is recognised by its # Written by beskar7-inspector comment and replaced. The fallback is optional: a full or read-only ESP skips it with a warning; any other write error fails the deploy. Limit: the Shell runs the first startup.nsh it finds, so one on an earlier mapping (BMC virtual media, another disk) runs instead, and it only sees disks the firmware connected before starting the Shell.

Clean mode (beskar7.mode=clean, v4.4): when a released host has spec.cleaningMode: Metadata, the controller boots the inspector in clean mode instead. It brings up the network, waits for the disk list to settle, and zeroes the first and last 8 MiB of every eligible disk (the same eligibility as target selection: physical, non-removable, writable, not backing the ramdisk) and of every partition on it. That removes the partition table, its GPT backup, COS_OEM with the previous join secret, and filesystem/RAID/LVM signatures. It then POSTs /api/v1/cleaned (or /api/v1/clean-failed if any disk failed or none was found) and powers off. It never inspects, fetches bootstrap data or writes an image. This is not a secure erase. The wipe only runs as PID 1; --dry-run lists what it would wipe and touches nothing.

power on → PXE → controller-rendered iPXE → inspector
              Phase 1: probe → POST report (202)
              Phase 2: GET bootstrap + networkdata → write image (digest-verified)
                       → UEFI boot entry for the ESP → inject COS_OEM config
                       → reboot → target OS

The wire contract — endpoints, cmdline parameters, the report schema, the digest-pinning trust model, and the disk/COS_OEM behavior — is specified in docs/inspector-contract.md in the beskar7 repo (the source of truth). This repo implements contract v4.4 (CONTRACT_VERSION in src/lib.rs).

Hardware support

The image boots Alpine's linux-lts kernel, which builds its storage and network drivers as modules. The initramfs ships a curated set of them (modules.list) and loads all of them at startup. A driver whose hardware is absent binds nothing.

Kind Families Drivers
Storage SATA (AHCI; legacy Intel PIIX/ICH) ahci, ata_piix
NVMe nvme
SAS HBAs and RAID: Broadcom/LSI MegaRAID, SAS2/SAS3 HBAs, SAS4 Tri-Mode; Microchip SmartPQI (HPE Smart Array Gen10+); HPE Smart Array before Gen10; Adaptec megaraid_sas, mpt3sas, mpi3mr, smartpqi, hpsa, aacraid
SCSI disks (SATA, SAS and RAID volumes appear as /dev/sdX) sd_mod
Virtual: virtio, VMware PVSCSI virtio_blk, virtio_scsi, vmw_pvscsi
Network Intel 1/2.5/10/25/40/100GbE e1000, e1000e, igb, igc, ixgbe, i40e, ice
Broadcom NetXtreme, NetXtreme II, NetXtreme-C/E tg3, bnx2, bnx2x, bnxt_en
NVIDIA/Mellanox ConnectX-3 and ConnectX-4+ mlx4_en, mlx5_core
Realtek r8169
Marvell/QLogic FastLinQ, Emulex OneConnect, Marvell/Aquantia AQtion, AMD/Solarflare, Chelsio T4–T6, Cisco UCS VIC qede, be2net, atlantic, sfc, cxgb4, enic
Virtual: virtio, VMware vmxnet3 virtio_net, vmxnet3
Filesystem ext4 (for the image's COS_OEM partition) ext4
FAT (for the image's ESP: the loader check and the startup.nsh fallback) vfat, nls_cp437, nls_ascii
efivarfs (for the disk's UEFI boot entry) efivarfs

Drivers that need device firmware get it from the image. At build time, every firmware file the shipped modules declare is copied into /lib/firmware, where the kernel loads it directly.

So far the image has been boot-tested only on QEMU's emulated NVMe, AHCI, PIIX and PVSCSI controllers and its igb, e1000e, e1000, vmxnet3 and virtio NICs. The other drivers are the kernel's upstream drivers and have not been tested on real hardware by this project.

If your NIC or storage controller is missing, the console shows no network interface found or no eligible target disk found. Please open an issue and include the output of lspci -nn from that host. Boot any Linux live image to get it.

Firmware licensing

The firmware in initrd.img is not covered by this project's Apache-2.0 license. It comes unmodified (only decompressed) from Alpine's linux-firmware-* packages, which repackage the upstream linux-firmware repository. Each file is redistributed under the terms its vendor set.

Those license texts ship with the firmware. They are vendored in firmware-licenses/: the LICENCE.*/LICENSE.* files, plus the WHENCE entries that map each shipped file to its license. Their upstream source and tag are recorded in that directory's README. The texts are copied:

  • into initrd.img at /lib/firmware/LICENSES/, beside the firmware;
  • into the container image at /firmware-licenses/.

The image build fails if it would ship a firmware file that those WHENCE entries do not cover.

Security posture

  • Verified TLS to the callback (rustls, CA delivered on the cmdline); no insecure-skip-verify on the report/bootstrap path.
  • The target image is integrity-checked by content digest, not TLS — it may be served over plain HTTP and is gated by beskar7.target-digest; the inspector never boots a non-matching image.
  • The join secret is written only to a 0600/root file on the verified COS_OEM partition, held in zeroizing buffers, and pinned out of swap with mlockall. The bearer token, boot nonce, full cmdline, and user-data are never logged.
  • Device identity is re-verified (st_rdev) before every destructive write, so a repointed /dev node cannot redirect the image or the join secret.

Build, test, lint

cargo test --all-targets                       # unit + contract tests
cargo fmt --all -- --check                     # formatting (CI-enforced)
cargo clippy --all-targets -- -D warnings      # lint (CI-enforced)
make check                                     # all three of the above
make image                                     # build build/vmlinuz + build/initrd.img
make test-vm                                   # boot the image in QEMU (Phase 1 smoke)

make image produces the two boot files (build/vmlinuz, build/initrd.img) from the multi-stage Dockerfile: it builds the static binary, assembles a minimal initramfs (the binary as /init, the curated kernel modules and the firmware they declare, and the mountpoints it needs), and takes the kernel from Alpine's linux-lts. An operator serves these two files to the boot infrastructure the controller's iPXE script points at.

Status: the inspector is feature-complete against contract v4.4 (incl. the provisioning-complete and provision-failed callbacks and clean mode) and fully unit- and contract-tested. make test-vm smoke-boots the image in QEMU (Phase 1 only — without a live callback the run stops after cmdline parsing). End-to-end boot (PXE → inspect → provision → reboot) is validated as part of Beskar7's integration/e2e work, not in this repo's CI (which runs fmt, clippy, and tests).

Layout

src/cmdline.rs      parse /proc/cmdline into the beskar7.* params
src/probe/          native hardware probing (SMBIOS/DMI + /sys + /proc)
src/report.rs       serde structs that serialize to the contract report schema
src/client.rs       rustls callback client: POST report (202), GET bootstrap
src/image.rs        digest-pinned streaming target-image fetch
src/target_disk.rs  target-disk selection
src/clean.rs        clean mode: zero both ends of every eligible disk and partition
src/esp.rs          locate the EFI System Partition (GPT type GUID) on the target disk
src/efiboot.rs      register the disk's UEFI boot entry over efivarfs (native efibootmgr)
src/oem.rs          locate the COS_OEM partition on the target disk
src/deploy.rs       whole-disk write + ESP loader check + COS_OEM mount/inject + reboot
src/run.rs          the PID-1 two-phase pipeline
src/main.rs         thin PID-1 entrypoint over run::run
tests/contract.rs   golden-fixture report round-trip (shared with beskar7)
modules.list        the curated kernel modules the image ships
firmware-licenses/  licence texts + WHENCE mapping for the shipped firmware

About

Hardware inspection RAM OS for Beskar7 Infrastructure Provider

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages