bootstrap: script de boot del builder en QEMU (rebuild in-rootfs)
scripts/boot-builder-vm.sh empaqueta el último eslabón operacional del SDD 11 §7: bootea work/builder.cpio.gz (el builder rootfs como initramfs cpio+gzip) con arje-zero como PID 1; en la consola se corre `rebuild-stage1` para reconstruir stage1' con el toolchain de adentro y comparar con la referencia. - Defaults: KERNEL=/boot/vmlinuz-linux, MEM=6144, CPU=Broadwell (AVX2 bajo TCG). - KVM=1 usa -enable-kvm -cpu host si hay /dev/kvm (mucho más rápido). - Documenta la tensión de RAM: el rootfs vive en tmpfs (~1.2 GB) + el rebuild Rust necesita varios GB más, todo en RAM; con host ~7 GB y sin KVM va justo/lento. El initramfs (410 MB gz, 26776 entradas) se verificó: sbin/init→arje-zero, el hammer estático, rebuild-stage1, rebuild.env y el toolchain/cargo presentes. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Semantic delta
No definition changed: this change is text, documentation or data.
1 files · +62 −0
- scripts/boot-builder-vm.sh +62 −0
diff --git a/scripts/boot-builder-vm.sh b/scripts/boot-builder-vm.sh
new file mode 100755
index 00000000..81aa8fa2
--- /dev/null
+++ b/scripts/boot-builder-vm.sh
@@ -0,0 +1,62 @@
+#!/usr/bin/env bash
+# boot-builder-vm.sh — Bootea el builder rootfs (Stage 1 + toolchain) en QEMU para correr el
+# rebuild in-rootfs (auto-alojamiento, SDD 11 §7; runbook §8c).
+#
+# El builder se arma con `hammer bootstrap builder … --out work/builder-rootfs` y se empaqueta como
+# initramfs (cpio newc + gzip). Aquí lo booteamos con arje-zero como PID 1: levanta hammerd + una
+# getty en consola y deja una shell. Desde ahí se corre el driver embebido:
+#
+# rebuild-stage1
+#
+# que reconstruye stage1' con el toolchain de adentro y compara su content-hash con la referencia
+# (REF_CONTENT en /etc/hammer/rebuild.env) → ✓ REPRODUCIBLE / ✗ DIVERGENTE.
+#
+# Variables (override por entorno):
+# INITRAMFS cpio.gz del builder (default work/builder.cpio.gz)
+# KERNEL bzImage/vmlinuz a bootear (default /boot/vmlinuz-linux)
+# MEM RAM de la VM en MiB (default 6144; el rootfs vive en RAM + espacio de build)
+# CPU modelo de CPU de QEMU (default Broadwell; AVX2 bajo TCG, sin -cpu host sin KVM)
+# KVM 1 ⇒ usa -enable-kvm -cpu host si hay /dev/kvm (mucho más rápido)
+#
+# RAM: el initramfs se desempaqueta a un tmpfs (~1.2 GB) y el rebuild Rust (arje-zero vendorea un
+# monorepo) necesita varios GB más, TODO en RAM. Con un host de ~7 GB y sin KVM esto va justo y lento
+# (TCG). Si el rebuild muere por OOM, sube MEM (y/o monta un disco para /work en vez de tmpfs).
+#
+# Uso:
+# ./scripts/boot-builder-vm.sh
+# MEM=12288 KVM=1 ./scripts/boot-builder-vm.sh
+
+set -euo pipefail
+
+REPO_ROOT="$(cd "$(dirname "$0")/.." && pwd)"
+INITRAMFS="${INITRAMFS:-$REPO_ROOT/work/builder.cpio.gz}"
+KERNEL="${KERNEL:-/boot/vmlinuz-linux}"
+MEM="${MEM:-6144}"
+CPU="${CPU:-Broadwell}"
+KVM="${KVM:-0}"
+
+[[ -f "$INITRAMFS" ]] || { echo "no existe el initramfs: $INITRAMFS (arma el builder y empaquétalo)" >&2; exit 1; }
+[[ -r "$KERNEL" ]] || { echo "no puedo leer el kernel: $KERNEL (set KERNEL=…)" >&2; exit 1; }
+
+accel=()
+if [[ "$KVM" == "1" && -w /dev/kvm ]]; then
+ accel=(-enable-kvm -cpu host)
+ echo "==> KVM activo (-cpu host)"
+else
+ accel=(-cpu "$CPU")
+ echo "==> TCG (sin KVM); -cpu $CPU por AVX2. Lento — el rebuild Rust puede tardar."
+fi
+
+echo "==> kernel : $KERNEL"
+echo "==> initramfs : $INITRAMFS ($(du -h "$INITRAMFS" | cut -f1))"
+echo "==> mem : ${MEM} MiB"
+echo "==> en la consola, tras el boot: corre rebuild-stage1"
+echo
+
+exec qemu-system-x86_64 \
+ -m "$MEM" \
+ -no-reboot -nographic \
+ "${accel[@]}" \
+ -kernel "$KERNEL" \
+ -initrd "$INITRAMFS" \
+ -append "console=ttyS0 rdinit=/sbin/init"