Skip to content

The ESP's committed-slot and version records are fsynced before they are renamed into place, and boot-success writes no record nothing reads - #251

Merged
DevomB merged 2 commits into
mainfrom
esp-records-fsync
Oct 9, 2026
Merged

DevomB merged 2 commits into
mainfrom
esp-records-fsync

Conversation

@DevomB

@DevomB DevomB commented Oct 7, 2026 •

Copy link
Copy Markdown
Owner

What was wrong. On FAT only the rename is not atomic, so Kryptik writes the kernels, BOOTX64.EFI and kryptik-recover's records (put) to a new name, fsyncs, and then renames. Two writers of one-line ESP records skipped the fsync:

  • boot-success's committed-slot, on every commit
  • kryptik-update's version-a/version-b, on every apply

A power cut between the rename and the later sync could leave the record pointing at a cluster that was never written. esp_slot/esp_version then read it as unknown, and since #238 an apply refuses because the ESP names no committed slot. That can be repaired with kryptik-recover --commit-slot, but it should not happen.

boot-success also copied version-X to version-committed on every commit. Nothing reads that file: no tool, suite or doc names it. kryptik-recover --commit-slot never updated it, so after a recovery it could name the wrong release.

What changed.

  • build/service-scripts/boot-success.sh: committed-slot.new is fsynced before the rename, and version-committed is no longer written. A copy left on an installed ESP is inert.
  • tools/update/kryptik-update: version-$target.new is fsynced before the rename.
  • docs/design/boot-and-updates.md: the apply and commit steps say the version file and committed-slot are written like the kernels. Its closing line no longer names "the two renames" as the only non-atomic steps, since there were four.
  • tools/tests/boot-success.sh: the sync stand-in now logs to a file of its own, kept out of the exact call sequences the other checks compare. The commit case checks that the new record is fsynced under its temporary name.

How the run proves it. CI's fixture step runs tools/tests/boot-success.sh, which includes the new check. The Distro run boots through commits and applies in the update, install and integrity suites, so the changed lines run on a real FAT ESP. It will be dispatched once main's run 37645250378 has saved its caches.

DevomB added 2 commits October 7, 2026 10:56
…are renamed into place, and boot-success writes no record nothing reads

On FAT only the rename is not atomic, so the kernels, BOOTX64.EFI and
kryptik-recover's records are written to a new name, fsynced, then renamed.
boot-success's committed-slot and kryptik-update's version-a/b skipped the
fsync: a power cut after the rename could leave the record with a cluster
that was never written, which the readers show as unknown and an apply then
refuses as naming no committed slot. Both now fsync first.

boot-success also copied version-X to version-committed on every commit.
Nothing reads it, and kryptik-recover --commit-slot never updated it, so it
could name the wrong release; it is no longer written.
…ed copy: the version and committed-slot records are written as the kernels are

It named two renames as the only non-atomic steps, and the version file and
committed-slot were renamed without an fsync before them.
@DevomB
DevomB marked this pull request as ready for review October 9, 2026 02:51
@DevomB
DevomB merged commit adf189d into main Oct 9, 2026
26 of 33 checks passed
@DevomB
DevomB deleted the esp-records-fsync branch October 9, 2026 03:53
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