# shellcheck shell=bash # cmd_init — create the storage layout. No ISOs downloaded yet (phase 3). cmd_init() { step "storage layout" mkdir -p "$LAB_ROOT"/images "$LAB_ROOT"/seeds "$LAB_ROOT"/run "$LAB_ROOT"/logs ok "LAB_ROOT ${LAB_ROOT}" # chattr +C must be set on the directory *before* any file is created in it, # otherwise btrfs keeps CoW for the existing tree. if [[ $(fstype_of "$LAB_ROOT") == btrfs ]]; then mkdir -p "$LAB_ROOT/images/base" "$LAB_ROOT/images/overlays" if chattr +C "$LAB_ROOT/images" 2>/dev/null; then if lsattr -d "$LAB_ROOT/images" 2>/dev/null | awk '{print $1}' | grep -q 'C'; then ok "images/ : +C set (CoW disabled)" else warn "images/ : chattr +C did not stick" fi else warn "images/ : chattr +C failed (btrfs?)" fi else mkdir -p "$LAB_ROOT/images/base" "$LAB_ROOT/images/overlays" info " images/ : $(fstype_of "$LAB_ROOT") — no +C needed" fi step "iso cache" if is_mounted "$LAB_ISO_CACHE" || is_mounted "$(dirname "$LAB_ISO_CACHE")"; then mkdir -p "$LAB_ISO_CACHE" ok "ISO cache ${LAB_ISO_CACHE}" else warn "ISO cache parent $(dirname "$LAB_ISO_CACHE") is not mounted — skipped" fi step "directories" for d in images/base images/overlays seeds run logs; do printf ' %-24s %s\n' "$d" "$([[ -d $LAB_ROOT/$d ]] && echo present || echo missing)" done printf '\n' ok "layout ready — next: ./lab.sh check" }