#!/bin/bash # bleach_zuse_img.sh - Reset disk/zuse.img back to pristine/unminted state. # # disk/zuse.img simulates the physical Zuse superuser thumbdrive for QEMU # testing (FABRIC-3.md, Phase 8 kickoff). "Bleaching" it means restoring the # all-zero blank state homeblocks_sig_check() reads as HOMEBLOCKS_SIG_BLANK # -- i.e. simulating a genuine first boot, so the one-time mint-Zuse flow can # be exercised repeatedly during development without hand-regenerating the # whole image each time. # # Deliberately a flat/raw image, not GPT-partitioned, matching the same # simplifying assumption homeblocks_sig_check()'s current call site in # repl.c uses (sig_start_fblock=0) -- both will need to move to a real # GPT-partition-relative offset together, once a GPT parser exists. Not # invented ahead of that work here. # # Usage: scripts/bleach_zuse_img.sh [path] # path Optional override; defaults to disk/zuse.img relative to repo root. set -euo pipefail REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" IMG="${1:-$REPO_ROOT/disk/zuse.img}" SIZE_MB=64 if [ -e "$IMG" ] && [ ! -f "$IMG" ]; then echo "bleach_zuse_img: refusing to overwrite non-regular-file '$IMG'" >&2 exit 1 fi dd if=/dev/zero of="$IMG" bs=1M count="$SIZE_MB" status=none echo "bleach_zuse_img: $IMG reset to ${SIZE_MB}MB blank (pristine/unminted)"