Fix expand-usb first-boot race that broke SSH on RC3 - #109
Merged
Conversation
RC3 shipped with a 10s wait for /dev/sda2 to appear after fdisk writes the partition table (added while investigating #90). That was only verified in isolation with the system otherwise idle; under real first-boot load, with many other services starting concurrently, the kernel can take longer than that to pick up the new partition. When it times out, ssh-keygen-boot.service fails outright (no partition to persist keys to), leaving no SSH host keys and sshd permanently unable to start - confirmed live on an actual fresh-flash boot of RC3. Bumped the wait to 60s and added an active partx -a -n 2 nudge on each iteration: fdisk's own in-place re-read (and blockdev --rereadpt) fail with "Device or resource busy" because a full re-read needs every partition on the disk free, including partition 1 which is normally still in use at this point in boot. partx adds just the one new partition via BLKPG instead, which isn't blocked by that. Reproduced and verified live: wiped partition 2 back to a genuinely fresh state, rebooted, and confirmed ssh-keygen-boot.service, ssh.service, and reflash.service all came up successfully - the partition took ~15-20s to appear under real boot load, well past the old 10s window but comfortably inside the new one.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
RC3 shipped with a real regression: `ssh-keygen-boot.service` fails on a genuinely fresh boot because the 10s wait for `/dev/sda2` to appear (added while investigating #90) isn't long enough under actual first-boot system load, only verified in isolation with the system otherwise idle. When it times out, no SSH host keys ever get generated and sshd is permanently unable to start (5 failed restarts, then gives up). `reflash.service` itself recovers on its own via its own internal retry loop, so the board looks like it's working from the touchscreen/web UI, but SSH access is broken.
Test plan
go test ./...andbats test/batspass🤖 Generated with Claude Code