Repository navigation
Unmount the LUKS key device before the initrd switches root - #20
Merged
Merged
Conversation
A boot that unlocks the root with rd.luks.key=...:UUID=<Boot> (the reset reboot, and its retry) mounts the Boot partition read-only at /run/systemd/cryptsetup/keydev-root. systemd-cryptsetup-generator's keydev-root-umount.service unmounts it after cryptsetup, but the isolate to initrd-switch-root.target starts [email protected]'s Requires= again, so the key-device mount and its unmount are queued a second time (systemd/systemd#28021). Nothing orders that unmount before initrd-switch-root.service, and it is Type=simple, so under load the root switches with the mount still in progress: the read-only ext4 superblock follows into the real root, /boot comes up "write-protected, mounted read-only", and owner setup's re-key fails in mkinitcpio. A drop-in in the initramfs orders the unmount before initrd-switch-root.service and makes it Type=oneshot, so the switch waits until the remount is undone. The encrypt test checks the drop-in and its install line and verifies it on the generator's unit; the VM harness now fails a boot whose /boot came up read-only, naming the cause.
The VM harness already lists the key-device mount drop-in in the generic initramfs it builds from the image's hooks; list the unmount drop-in too, so an image built without it fails before any boot. grep reads the whole listing, so lsinitcpio never sees a closed pipe under pipefail.
maralcbr
marked this pull request as ready for review
October 8, 2026 20:54
scottjones
added a commit
that referenced
this pull request
Oct 9, 2026
Brings in #18, #19, #20 and #22. The runtime pin conflicted: main pins omacom/omarchy 4d9bdc49 (#14431), which has no platform-root fingerprint detection, so this branch now pins omacom/omarchy#14675's head f317ea50, the fingerprint-readers detector on #14431. Move it to the merge commit once #14675 lands. omarchy-mac stays at #12's 0.2.0; main is still at 0.1.0. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
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
A factory-reset reboot can bring
/bootup read-only, and owner setup then fails its LUKS re-key because mkinitcpio cannot write/boot/initramfs-linux-aurora.img. It is a race in the initramfs, seen in VM acceptance of omacom/omarchy#14431 while another VM shared the host.Cause. The reset reboot (and its retry) unlocks the root with
rd.luks.key=<luks>=/omarchy/luks-key:UUID=<Boot>. systemd-cryptsetup-generator then mounts the Boot partition read-only at/run/systemd/cryptsetup/keydev-rootand unmounts it withkeydev-root-umount.serviceafter cryptsetup. Wheninitrd-cleanup.serviceisolates toinitrd-switch-root.target, the transaction starts[email protected]again, and itsRequires=/Wants=queue the key-device mount and its unmount a second time. This is open upstream as systemd/systemd#28021. Nothing orders that unmount beforeinitrd-switch-root.service, and the generated unit isType=simple, so it counts as started at fork. Under load the root switches while the mount is in progress or beforeumounthas run. The read-only ext4 superblock follows into the real root, andboot.mountgetsmount: /boot: WARNING: source write-protected, mounted read-only.Fix. The omarchy-mac-encrypt install hook adds a drop-in for the generated unit,
keydev-root-umount.service.d/omarchy-mac-encrypt.conf, withBefore=initrd-switch-root.serviceandType=oneshot. The switch now waits for the second unmount, which already waits for the second mount. The drop-in exists only in the initramfs, and only takes effect on boots whose command line carriesrd.luks.key=(the generator creates no such unit otherwise). The unit name follows the volume nameroot, the same assumption the existing key-device mount drop-in makes.Tests:
mac-encrypt-test.shchecks the drop-in and its install line and runssystemd-analyze verifyon a copy of the generator's unit with the drop-in; it fails without the fix. The VM harness now checks that the generic initramfs carries the drop-in, and fails a boot whose serial log shows/bootcame up read-only (inowner_setupandno_emergency), naming the cause instead of a later mkinitcpio error.Evidence
Failing run: 14431 acceptance run b,
factory-reset-reboot-serial.log: secondMounting /run/systemd/cryptsetup/keydev-rootat 6.90 s,Switching rootat 6.95 s, vda2 mounted ro at 6.956 s,/boot: WARNING: source write-protectedat 9.47 s.Repeated initrd boots of one reset-staged disk on the M1 Pro (KVM, 4 vCPU, two guests at a time; the "load" rounds add six busy loops on the host). The only difference between the two initramfs images is the drop-in, appended to the control image's initramfs.
/bootread-onlyWith the drop-in every boot logs
Finished keydev-root-umount.servicetwice beforeSwitching root.Full VM acceptance with omarchy-mac-boot built from this branch (2b88c06) on the #14431 test set (only omarchy-mac-boot changed), harness 14499e9, each factory-reset run in parallel with an update run: 3 of 3 factory-reset runs 13 ok / 0 not ok, 3 of 3 update runs 12 ok / 0 not ok. Each reset reboot logs two key-device mounts and two finished unmounts before
Switching root, and no read-only/boot. A control factory-reset run on the unpatched set passed (13/0/0): the race is timing, which is why the boot loop above is the reproduction.Unit tests:
omarchy-mac-boot/test/all221 ok in an Arch Linux ARM container;tools/acceptance/test/mac-image-run-test.shpasses.Merge Danger
Door: two-way
One initramfs drop-in; reverting it and rebuilding the initramfs restores today's behaviour.
Blast Radius: small
Only Mac initramfs images built with the omarchy-mac-encrypt hook, and only boots with
rd.luks.key=(reset reboot and its retry). Those boots wait for one local unmount before switching root. No x86 or desktop effect, no user-visible setting.