Closes the full arc: banger kernel pull + image pull + vm create + vm ssh now works end-to-end against docker.io/library/debian:bookworm with zero manual image building. Generic kernel: - New scripts/make-generic-kernel.sh builds vmlinux from upstream kernel.org sources using Firecracker's official minimal config (configs/firecracker-x86_64-6.1.config). All critical drivers (virtio_blk, virtio_net, ext4, vsock) compiled in — no modules, no initramfs needed. - Published as generic-6.12 in the catalog (kernels.thaloco.com). - catalog.json updated with the new entry. Direct-boot init= override (vm_lifecycle.go): - For images without an initrd (direct-boot / OCI-pulled), banger now passes init=/usr/local/libexec/banger-first-boot on the kernel cmdline. The script runs as PID 1, mounts /proc /sys /dev /run, checks for systemd — if present execs it immediately; if not (container images), installs systemd-sysv + openssh-server via the guest's package manager, then execs systemd. - Also passes kernel-level ip= parameter via BuildBootArgsWithKernelIP so the kernel configures the network interface before init runs (container images don't ship iproute2, so the userspace bootstrap script can't call ip(8)). - Masks dev-ttyS0.device and dev-vdb.device systemd units that otherwise wait 90s for udev events that never fire in Firecracker guests started from container rootfses. first-boot.sh rewritten as universal init wrapper: - Works as PID 1 (mounts essential filesystems) OR as a systemd oneshot (existing behavior). - Installs both systemd-sysv AND openssh-server (container images have neither). - Dispatch updated: debian, alpine, fedora, arch, opensuse families + ID_LIKE fallback. All tests updated. Opencode capability skip for direct-boot images: - The opencode readiness check (WaitReady on vsock port 4096) now returns nil for images without an initrd, since pulled container images don't ship the opencode service. Without this, the VM would be marked as error for lacking an opinionated add-on. Docs: README and kernel-catalog.md updated to recommend generic-6.12 as the default kernel for OCI-pulled images. AGENTS.md notes the new build script. Verified live: - banger kernel pull generic-6.12 - banger image pull docker.io/library/debian:bookworm --kernel-ref generic-6.12 - banger vm create --image debian-bookworm --name testbox --nat - banger vm ssh testbox -- "id; uname -r; systemctl is-active banger-vsock-agent" → uid=0(root), kernel 6.12.8, Debian bookworm, vsock-agent active, sshd running, SSH working. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
96 lines
2.9 KiB
Bash
Executable file
96 lines
2.9 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
# make-generic-kernel.sh
|
|
#
|
|
# Build a minimal Firecracker-optimized vmlinux from upstream kernel.org
|
|
# sources using the vendored Firecracker config. All essential drivers
|
|
# (virtio_blk, virtio_net, ext4, vsock) are compiled in — no modules,
|
|
# no initramfs needed. The result boots any OCI-pulled rootfs directly.
|
|
#
|
|
# Usage:
|
|
# scripts/make-generic-kernel.sh [--version 6.12.8]
|
|
#
|
|
# Output:
|
|
# build/manual/generic-kernel/boot/vmlinux-<version>
|
|
# build/manual/generic-kernel/metadata.json
|
|
|
|
set -euo pipefail
|
|
|
|
log() { printf '[make-generic-kernel] %s\n' "$*" >&2; }
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
REPO_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
|
|
OUT_DIR="${BANGER_MANUAL_DIR:-$REPO_ROOT/build/manual}/generic-kernel"
|
|
CONFIG="$REPO_ROOT/configs/firecracker-x86_64-6.1.config"
|
|
KERNEL_VERSION="${KERNEL_VERSION:-6.12.8}"
|
|
KERNEL_MAJOR="${KERNEL_VERSION%%.*}"
|
|
JOBS="${JOBS:-$(nproc)}"
|
|
|
|
usage() {
|
|
cat <<EOF
|
|
usage: scripts/make-generic-kernel.sh [--version <ver>]
|
|
|
|
Downloads kernel <ver> from kernel.org, applies the vendored Firecracker
|
|
config, and builds a minimal vmlinux. Default version: $KERNEL_VERSION
|
|
|
|
Output: $OUT_DIR/boot/vmlinux-<ver>
|
|
EOF
|
|
}
|
|
|
|
while [[ $# -gt 0 ]]; do
|
|
case "$1" in
|
|
--version) KERNEL_VERSION="$2"; KERNEL_MAJOR="${KERNEL_VERSION%%.*}"; shift 2;;
|
|
-h|--help) usage; exit 0;;
|
|
*) log "unknown arg: $1"; exit 1;;
|
|
esac
|
|
done
|
|
|
|
for tool in curl tar make gcc; do
|
|
command -v "$tool" >/dev/null 2>&1 || { log "missing required tool: $tool"; exit 1; }
|
|
done
|
|
[[ -f "$CONFIG" ]] || { log "config not found: $CONFIG"; exit 1; }
|
|
|
|
TARBALL="linux-${KERNEL_VERSION}.tar.xz"
|
|
URL="https://cdn.kernel.org/pub/linux/kernel/v${KERNEL_MAJOR}.x/$TARBALL"
|
|
SRC_DIR="$(mktemp -d)"
|
|
trap 'rm -rf "$SRC_DIR"' EXIT
|
|
|
|
log "downloading kernel $KERNEL_VERSION from $URL"
|
|
curl -fSL --progress-bar -o "$SRC_DIR/$TARBALL" "$URL"
|
|
|
|
log "extracting"
|
|
tar -xf "$SRC_DIR/$TARBALL" -C "$SRC_DIR" --strip-components=1
|
|
|
|
log "applying firecracker config"
|
|
cp "$CONFIG" "$SRC_DIR/.config"
|
|
# Adapt the 6.1 config to whatever version we're building. make olddefconfig
|
|
# fills in any new symbols with defaults.
|
|
make -C "$SRC_DIR" olddefconfig >/dev/null 2>&1
|
|
|
|
log "building vmlinux (jobs=$JOBS)"
|
|
make -C "$SRC_DIR" -j"$JOBS" vmlinux 2>&1 | tail -5
|
|
|
|
VMLINUX="$SRC_DIR/vmlinux"
|
|
if [[ ! -f "$VMLINUX" ]]; then
|
|
log "vmlinux not found after build; check build output above"
|
|
exit 1
|
|
fi
|
|
|
|
mkdir -p "$OUT_DIR/boot"
|
|
DEST="$OUT_DIR/boot/vmlinux-${KERNEL_VERSION}"
|
|
cp "$VMLINUX" "$DEST"
|
|
|
|
log "verifying: $(file -b "$DEST" | head -c 80)"
|
|
|
|
cat > "$OUT_DIR/metadata.json" <<EOF
|
|
{
|
|
"kernel_path": "$DEST",
|
|
"kernel_version": "$KERNEL_VERSION",
|
|
"config": "firecracker-x86_64-6.1"
|
|
}
|
|
EOF
|
|
|
|
log "done: $DEST ($(du -h "$DEST" | cut -f1))"
|
|
log "no initrd or modules needed — all drivers are built-in"
|
|
log ""
|
|
log "next steps:"
|
|
log " banger kernel import generic-${KERNEL_VERSION%%.*}.${KERNEL_VERSION#*.} --from $OUT_DIR --distro generic --arch x86_64"
|