From b54bfa84ef496d785e7f70fdc633302a3708302c Mon Sep 17 00:00:00 2001 From: rob Date: Thu, 9 Jul 2026 07:22:13 +0000 Subject: [PATCH] slowdisk fit check: 90d growth headroom (statics grow; /slowdisk is often the root partition) Co-Authored-By: Claude Fable 5 --- restore-volumes.sh | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/restore-volumes.sh b/restore-volumes.sh index f9631218..90eb2147 100755 --- a/restore-volumes.sh +++ b/restore-volumes.sh @@ -113,16 +113,20 @@ prep_static_offload() { # When the statics do NOT fit, FAIL LOUDLY instead of silently extracting everything # onto the primary disk: a silent NVMe fallback violates the caller's capacity math # (operator directive 2026-07-09). --no-slowdisk is the conscious override. - local need_gb free_gb floor_gb + local need_gb free_gb floor_gb growth_pct floor_gb="${SLOWDISK_FLOOR_GB:-150}" + # Static files GROW (reth appends segments as the chain advances, ~5%/mo), and /slowdisk + # is usually the SATA root partition — filling it starves the OS/logs. Each offload must + # bring its own 90d growth headroom on top of the floor (operator directive 2026-07-09). + growth_pct="${SLOWDISK_GROWTH_PCT:-15}" free_gb=$(slowdisk_free_gb || echo "") - need_gb=$(awk 'NR>3 && NF>=2 { + need_gb=$(awk -v g="$growth_pct" 'NR>3 && NF>=2 { s=$1; mult=1 if (s ~ /TB$/) mult=1024; else if (s ~ /MB$/) mult=1/1024; else if (s ~ /KB$/) mult=1/1048576 gsub(/[A-Za-z]/, "", s); total+=s*mult - } END {printf "%d", total*1.05 + 1}' "$meta") + } END {printf "%d", total*1.05*(1+g/100) + 1}' "$meta") if [[ "$free_gb" =~ ^[0-9]+$ && "$need_gb" =~ ^[0-9]+$ ]] && (( free_gb - need_gb < floor_gb )); then - echo "ERROR: static offload does not fit on /slowdisk (need ~${need_gb}G static files, free ${free_gb}G, floor ${floor_gb}G)." >&2 + echo "ERROR: static offload does not fit on /slowdisk (need ~${need_gb}G incl. ${growth_pct}% growth headroom, free ${free_gb}G, floor ${floor_gb}G)." >&2 echo " This restore can only fit with --no-slowdisk (extracts everything onto the" >&2 echo " primary disk — NVMe capacity accounting will differ from the offload plan)." >&2 exit 1