Skip to content

os/v3/puppy: a written stick grows its data partition to the medium on first boot - #3301

Merged
bong-water-water-bong merged 2 commits into
mainfrom
os/grow-stick-data
Nov 22, 2026
Merged

bong-water-water-bong merged 2 commits into
mainfrom
os/grow-stick-data

Conversation

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator

Part of #3287 ("The stick's data partition is not grown on first boot").

Problem. A dd-written stick keeps the image's 8 GB 1BIT-DATA: on v2026.47, a 64 GB stick had an 8 GB /data that the two demo models nearly filled. os/mini grows at prepare time (prepare-stick.sh); the Puppy image is written and booted, and its data partition is also the boot medium (the SFS set and the save layer live on it), mounted before init runs.

Change. 05onboard-data runs the new /usr/local/sbin/1bit-grow-data right after mounting /data. It is the online grow cloud images use (growpart): relocate the backup GPT to the end of the device (a dd'd image leaves it at the end of the image), rewrite the partition entry with sfdisk --no-reread, tell the kernel with partx -u (BLKPG resize works on a mounted partition), resize2fs the mounted ext4. The start sector never changes; nothing is unmounted.

It acts only when all hold, otherwise prints why and exits 0 (an ungrown stick still works): removable USB disk (an installed disk is created full-size by 1bit-install), the last partition, ≥ 1 GiB free after it, ext4 mounted at /data, no /data/.grown marker yet.

Test. tests/grow_data_test.sh (needs root + loop devices; exits 77 otherwise): a 4 GiB loop "stick" with a dd'd image's layout, partition mounted during the grow:

ok   a disk that is not removable USB is not grown
ok   the mounted filesystem grew to the end of the disk (1510792 -> 3572460 KiB)
ok   a file written before the grow reads back byte for byte
ok   the marker is written
ok   a second run does nothing
ok   the filesystem checks clean after the online grow

Not yet run on a real stick boot: the appliance's sfdisk/partx/resize2fs versions are still to be confirmed on the hardware.

🤖 Generated with Claude Code

…n first boot (engine#3287)

A dd-written stick kept the image's 8 GB 1BIT-DATA partition, which the demo models alone nearly fill (v2026.47:
64 GB stick, 8 GB /data). os/mini grows at prepare time; the Puppy image is written and booted, and its data
partition is also the boot medium (SFS set + save layer), mounted before init. So 05onboard-data now runs
/usr/local/sbin/1bit-grow-data after mounting /data: the online grow cloud images use (backup GPT relocated,
entry rewritten without a re-read, partx -u, resize2fs on the mounted ext4; the start sector never changes).

It acts only on removable USB, on the last partition, with >= 1 GiB free, ext4 mounted at /data, and once (the
/data/.grown marker); anything else is a printed reason and exit 0. tests/grow_data_test.sh proves it on a
loop-device stick laid out like a written image, mounted while it grows: 1.5 -> 3.5 GiB, a 64 MB file byte-
identical after, a second run a no-op, a non-USB disk untouched, e2fsck clean. (root + loop devices; 77 = skip.)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@github-actions

github-actions Bot commented Nov 22, 2026 •

Copy link
Copy Markdown

PR Reviewer Guide 🔍

(Review updated until commit 7d58ba7)

Here are some key observations to aid the review process:

🎫 Ticket compliance analysis 🔶

3287 - Partially compliant

Compliant requirements:

  • The stick's data partition is now grown on first boot when the conditions are met

Non-compliant requirements:

  • The writer running prepare-stick.sh to grow by default is not implemented in this PR

Requires further human verification:

  • The actual behavior on a real stick boot needs verification (the appliance's sfdisk/partx/resize2fs versions are still to be confirmed on the hardware)
⏱️ Estimated effort to review: 3 🔵🔵🔵⚪⚪
🧪 PR contains tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

Potential Data Loss on Resize Failure

If resize2fs fails to grow the filesystem, the partition will be larger but the filesystem will retain its original size. This could lead to data loss or corruption if the system attempts to write beyond the original filesystem boundaries. The script logs this condition but does not prevent further operations or alert the user. This issue was previously reported and remains in the current code.

    say "resize2fs did not grow the filesystem: the partition is larger, the filesystem keeps its size until the next try"
fi
GPT Relocation Failure Tolerance

The script attempts to relocate the backup GPT but only logs a failure without halting execution. If the relocation fails, the subsequent sfdisk command may not work correctly, potentially leading to an inconsistent partition table. This could cause data corruption or prevent future growth attempts. This issue was previously reported and remains in the current code.

sfdisk --relocate gpt-bak-std "/dev/$disk" > /dev/null 2>&1 || say "could not relocate the backup GPT (continuing)"
✅ Resolved findings

os/v3/puppy/embed/usr/local/sbin/1bit-grow-data:64

GPT Relocation Failure Tolerance

The script attempts to relocate the backup GPT but only logs a failure without halting execution. If the relocation fails, the subsequent sfdisk command may not work correctly, potentially leading to an inconsistent partition table. This could cause data corruption or prevent future growth attempts.

os/v3/puppy/embed/usr/local/sbin/1bit-grow-data:73-74

Potential Data Loss on Resize Failure

If resize2fs fails to grow the filesystem, the partition will be larger but the filesystem will retain its original size. This could lead to data loss or corruption if the system attempts to write beyond the original filesystem boundaries. The script logs this condition but does not prevent further operations or alert the user.

tests_referenced refused an unregistered tests/grow_data_test.sh, which also failed pre_pr_checks_tree. The row
needs root and loop devices; the CI container has neither, so it skips there and is baselined with that reason.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@github-actions

Copy link
Copy Markdown

Persistent review updated to latest commit 7d58ba7

@bong-water-water-bong
bong-water-water-bong merged commit c98dcdb into main Nov 22, 2026
11 of 12 checks passed
@bong-water-water-bong
bong-water-water-bong deleted the os/grow-stick-data branch November 22, 2026 14:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant