Reserving 8 GiB headroom between ISO and persistence partitions.

The persistence partition is created immediately after the ISO partition
ends (1-MiB aligned).  When `wrolpi-usb.sh upgrade` overwrites the ISO
partition with a future, possibly-larger ISO, growth past the current
ISO size would overwrite persistence-partition sectors.

Reserve 8 GiB between them on first boot.  Future ISO releases up to
roughly 2x the current size (~3.3 GB) can be written into that gap
without touching persistence.

The cost is ~8 GiB of persistence the user can't reclaim.  On a typical
128 GB USB this is ~6% of total capacity, which is comparable to
filesystem overhead and rounding loss.

Existing USBs flashed before this commit have no headroom — they need
a one-time backup-and-reflash to pick it up.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Roland 2026-05-24 21:19:07 -06:00
parent 76f28ae86a
commit 7310f3eb80
No known key found for this signature in database
GPG key ID: 1BA620CE6C9A4680

View file

@ -86,7 +86,15 @@ if [ -n "$BOOT_DRIVE" ]; then
log "ERROR: failed to compute LAST_END from $BOOT_DRIVE partition table"
exit 1
fi
START=$(( ((LAST_END + 2047) / 2048) * 2048 ))
# Reserve 8 GiB of unused space between the ISO partition and the new
# persistence partition. The `wrolpi-usb.sh upgrade` tool overwrites
# the ISO partition with a (potentially larger) new ISO; without
# headroom, growth past the current ISO size would clobber the
# persistence partition's data. 8 GiB covers ~2x the current ISO
# size — enough for several future releases. Cost: ~8 GiB of
# persistence space the user doesn't see.
HEADROOM_SECTORS=$(( 8 * 1024 * 1024 * 1024 / 512 ))
START=$(( (((LAST_END + HEADROOM_SECTORS) + 2047) / 2048) * 2048 ))
# --no-reread --force: required because the live medium is mounted from
# this same drive. Adding a new partition entry past the mounted one
# is safe; we use partx -a below to inform the running kernel without