google/build-initrd
Initrd repack and guest binary management for Capsem. Use when adding new guest binaries, modifying capsem-init, changing the initrd repack process, or understanding which binaries get injected at boot vs baked into the rootfs. Covers the fast iteration loop, binary list, and how to add new guest binaries.
npx skills add https://github.com/google/capsem --skill build-initrd
just exec automatically repacks the initrd before every boot. It cross-compiles guest binaries, injects them into the initrd, and capsem-init prefers initrd-bundled copies over rootfs copies at boot. This is the fast iteration loop (~10s) -- no full rootfs rebuild needed for guest binary changes.
| Binary | What it does |
|--------|-------------|
| capsem-init | PID 1 init script |
| capsem-pty-agent | PTY-over-vsock bridge agent |
| capsem-net-proxy | TCP-to-vsock relay for air-gapped HTTPS proxying |
| capsem-mcp-server | MCP stdio-to-vsock relay for AI agent tool access |
| capsem-sysutil | Guest suspend helper via vsock:5004; in-VM shutdown commands are disabled |
| capsem-doctor | VM self-diagnostic suite (bash script) |
| snapshots | Snapshot management CLI (Python, FastMCP client) |
| diagnostics/ | pytest test files for capsem-doctor |
Update three places:
_pack-initrd recipe in justfile -- add the cross-compile + copy stepcapsem-init in guest/artifacts/capsem-init -- add initrd-bundled fallback logic (check /binary before rootfs path)| Changed | Command | Why |
|---------|---------|-----|
| Guest binary source (Rust agent code) | just exec | Auto-repacks initrd with new binary |
| capsem-init script | just exec | Init script is repacked into initrd |
| guest/artifacts/diagnostics/*.py | just exec "capsem-doctor" | Test files repacked into initrd |
| guest/artifacts/capsem-bashrc | just _build-assets | Baked into rootfs, not initrd |
| Profile package/root/build inputs (config/profiles/<id>/) | just _build-assets | Affects profile-derived rootfs rendering |
| Installed packages (apt, pip) | just _build-assets | Baked into the profile rootfs asset |
All guest binaries are deployed read-only:
chmod 555 in Dockerfile template (rootfs mounted read-only)chmod 555 in _pack-initrd and capsem-init after copying to tmpfsThe initrd is a gzip+cpio archive. _pack-initrd in the justfile:
cross_compile_agent() (on macOS: container build; on Linux: native cargo) -- outputs to target/linux-agent/{arch}/assets/{arch}/initrd.imgAt boot, capsem-init checks if a binary exists in the initrd bundle (/binary) before falling back to the rootfs path. This means initrd copies always take priority.
Guest binary permissions must be 555 (read+execute, no write). There are two independent places that set permissions and both must agree:
chmod 555 when copying into the profile rootfs asset_pack-initrd -- chmod when copying into the initrd (overlays rootfs at boot)The initrd copy WINS at runtime because it overlays the rootfs. So even if the Dockerfile says 555, if the justfile says 755, the guest sees 755. When fixing permissions, always check both places. A rootfs rebuild (just _build-assets) alone won't fix it if the initrd repack still sets the wrong mode.
Take google/build-initrd from the repository into ~/.claude/skills for personal
use, or into .claude/skills inside a project.
The agent identifies a skill by the name field in its header. Two skills with the
same name cannot sit side by side — one of them will be ignored.