From 7310f3eb80071acb8e9c7ecc4d205a28770a906b Mon Sep 17 00:00:00 2001 From: Roland Date: Sun, 24 May 2026 21:19:07 -0600 Subject: [PATCH] Reserving 8 GiB headroom between ISO and persistence partitions. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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) --- .../includes.chroot/usr/local/sbin/wrolpi-bootstrap.sh | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/debian-live-config/config/includes.chroot/usr/local/sbin/wrolpi-bootstrap.sh b/debian-live-config/config/includes.chroot/usr/local/sbin/wrolpi-bootstrap.sh index 29df4f81..a5b12c03 100644 --- a/debian-live-config/config/includes.chroot/usr/local/sbin/wrolpi-bootstrap.sh +++ b/debian-live-config/config/includes.chroot/usr/local/sbin/wrolpi-bootstrap.sh @@ -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