Skip to content

Fix expand-usb first-boot race that broke SSH on RC3 - #109

Merged
eliasbakken merged 1 commit into
mainfrom
fix/expand-usb-first-boot-race
Aug 11, 2026
Merged

Fix expand-usb first-boot race that broke SSH on RC3#109
eliasbakken merged 1 commit into
mainfrom
fix/expand-usb-first-boot-race

Conversation

@eliasbakken

Copy link
Copy Markdown
Contributor

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.

  • Bumped the wait to 60s
  • Added an active `partx -a -n 2` nudge each iteration - fdisk's own re-read (and `blockdev --rereadpt`) fail with "Device or resource busy" since a full re-read needs every partition free, including partition 1 which is normally still in use at this point in boot; `partx` adds just the new partition via BLKPG instead, which isn't blocked by that

Test plan

  • Reproduced live: wiped partition 2 back to a genuinely fresh state on real hardware, rebooted, confirmed the old code's failure mode
  • Verified the fix live: same wipe + reboot, confirmed `ssh-keygen-boot.service`, `ssh.service`, and `reflash.service` all came up successfully - partition took ~15-20s to appear under real load, past the old 10s window, inside the new one
  • go test ./... and bats test/bats pass

🤖 Generated with Claude Code

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.
@eliasbakken
eliasbakken merged commit 86bcaee into main Aug 11, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant