Skip to content

Always unmount the config partition in get-recore-serial-number - #100

Merged
eliasbakken merged 1 commit into
mainfrom
fix/serial-number-stale-mount
Aug 10, 2026
Merged

Always unmount the config partition in get-recore-serial-number#100
eliasbakken merged 1 commit into
mainfrom
fix/serial-number-stale-mount

Conversation

@eliasbakken

Copy link
Copy Markdown
Contributor

Summary

set -euo pipefail means a missing serial_number file (a board that hasn't been provisioned yet - exactly the case this script exists to detect) makes cat fail and the script exit before reaching unmount-config, leaving the mount - and its transient systemd unit - dangling. That stale mount can then make a later mount-config call fail with Unit mnt-config.mount was already loaded.

Use a trap so the unmount always runs once the mount has succeeded, regardless of how the read afterward turns out.

Testing

  • make test-bats - added a regression test asserting unmount-config is still called when serial_number is missing.
  • Live-tested on real hardware: deleted serial_number, confirmed the script now fails cleanly (exit 1, no stale /mnt/config mount) instead of leaving it mounted, then restored the serial number via create-recore-config and confirmed the whole flow (including the UI popup) still works.

Found while testing #83/#85.

set -euo pipefail means a missing serial_number file (a board that
hasn't been provisioned yet - exactly the case this script exists to
detect) makes cat fail and the script exit before reaching
unmount-config, leaving the mount - and its transient systemd unit -
dangling. That stale mount can then make a later mount-config call
fail with "Unit mnt-config.mount was already loaded".

Use a trap so the unmount always runs once the mount has succeeded,
regardless of how the read afterward turns out.

Live-tested on real hardware: deleted serial_number, confirmed the
script now fails cleanly (exit 1, no stale mount) instead of leaving
/mnt/config mounted, then restored the serial number via
create-recore-config and confirmed the whole flow still works.
@eliasbakken
eliasbakken merged commit 94bc543 into main Aug 10, 2026
2 checks passed
@eliasbakken
eliasbakken deleted the fix/serial-number-stale-mount branch August 10, 2026 19:37
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