Skip to content

Mount /boot/efi and /boot from the ESP the Mac booted - #229

Open
allanclempe wants to merge 1 commit into
omacom:mainfrom
allanclempe:oms-31-mount-boot-from-the-booted-esp
Open

allanclempe wants to merge 1 commit into
omacom:mainfrom
allanclempe:oms-31-mount-boot-from-the-booted-esp

Conversation

@allanclempe

Copy link
Copy Markdown

Fixes #219, using the issue's second fix, as @TripleU613 suggested there.

What breaks

Every image mounts the ESP by UUID=4F4D-5801 and /boot by 4f4d5801-424f-4f54-8000-000000000001. With a second install on the disk, or the partitions of an earlier install attempt, fstab can mount the other install's ESP or Boot partition, and kernel and boot updates are written where this Mac never reads them. #219 has both cases: two installs on a J714s, and a leftover attempt on a J616c.

The fix

image-builder/builder/omarchy-esp-generator is a systemd generator. build-mac-image installs it at /usr/local/lib/systemd/system-generators/. It writes into the early generator directory, so its units replace the ones systemd-fstab-generator makes from fstab:

  • boot-efi.mount for the PARTUUID in /proc/device-tree/chosen/asahi,efi-system-partition, the ESP the Mac booted from (as omarchy-mac-esp reads it).
  • boot.mount for the partition that starts next after that ESP on the same disk, by start sector from sysfs, and only when its ext4 superblock carries the image's Boot UUID.
  • Each mount keeps fstab's type, options and fsck.

When it can't tell, it writes nothing for that mount and fstab stays in charge: no property, a value that isn't one PARTUUID, the ESP's PARTUUID on two partitions, or no matching Boot partition. It logs why to the kernel log. fstab is unchanged, so check_fstab and a plain mount /boot behave as before.

mac-image-check now requires the generator in the image, mode 0755, byte for byte the builder's copy.

Tested

  • image-builder/test/omarchy-esp-generator-test.sh (new, picked up by test/all) models the J616c disk from Every image gives /boot and the ESP the same filesystem IDs; with two installs on one disk, fstab can mount the other install's partitions #219, leftovers included. It checks that both units match what systemd-fstab-generator makes from the image's fstab lines and pass systemd-analyze verify. It also checks the fallbacks: another ext4 UUID, no ext4 magic, an unreadable device, no partition after the ESP, a reused slot number, a duplicated ESP PARTUUID and malformed properties.
  • test_mac_image_check.py: 4 new tests for the image check. The test file passes (61 tests).
  • Arch Linux x86_64 (Bash 5.3.20, Python 3.14.8, systemd 262.1): the new shell test, mac-image-inputs-test.sh and the Python tests pass. build-mac-image-test.sh stops on this host with "hyprland-0.52.0-1-aarch64 does not have a valid architecture", and does the same on unmodified main.
  • The same generator has run in our J616c image since 2026-11-15. On a fresh install, /boot/efi and /boot came from the right partitions, both mounted from /run/systemd/generator.early/. With a leftover ESP still on the disk, it picked the booted one.
  • Not tested: an image built by this branch's build-mac-image (that needs an aarch64 host with Docker), other models, an unencrypted root, and M1 to M3 Stage 2s whose property isn't a PARTUUID. In that last case it writes nothing and fstab applies.

@TripleU613, you offered to try it on the J714s with two installs. That's the case this most needs.

@TripleU613

Copy link
Copy Markdown

Tested on a MacBook Pro 14" M5 Pro (J714s): one Omarchy install, encrypted root, our J714s build of kernel 7.3.0 (v272-18). I ran the generator from this PR's head (omarchy-esp-generator, sha256 d73f2168fb8d5b5b…) by hand as root, with scratch directories in place of systemd's generator directories, so nothing on the system changed:

  • The device tree names ESP 785f310e-…, which is nvme0n1p4.
  • It wrote boot-efi.mount for 785f310e-… (p4), and boot.mount for e55f3fe8-… (p5, ext4 OMARCHY_BOOT), each with its local-fs.target.requires link. Exit 0.
  • These are the partitions mounted at /boot/efi and /boot on this boot.
  • Kernel log: "mounting /boot/efi from PARTUUID 785f310e-…, the ESP this Mac booted from" and "mounting /boot from PARTUUID e55f3fe8-… (nvme0n1p5), the partition after the ESP".

Not tested here: two installs or a leftover ESP on this disk (it has one install now), and a boot with the generator installed.

🤖 Generated with Claude Code

Every image mounts the ESP and /boot by IDs every image shares, so with a
second install or a leftover attempt on the disk, fstab can mount the other
install's partitions (omacom#219). The image now carries a systemd generator that
mounts /boot/efi from the ESP the Stage 2 names in the device tree, and /boot
from the partition after it when that is the image's Boot filesystem. When it
can't tell, fstab stays in charge. mac-image-check requires it.
@allanclempe
allanclempe force-pushed the oms-31-mount-boot-from-the-booted-esp branch from 8f547a3 to 09bfb52 Compare December 1, 2026 01:35
@allanclempe

allanclempe commented Dec 1, 2026 •

Copy link
Copy Markdown
Author

[Allan's agent]

@TripleU613 Thanks for running it on the J714s. A second Apple silicon generation choosing the right ESP and Boot partition from the device tree is the main thing this needed.

Rebased onto main (e0aa53f) as 09bfb52; the only conflict was two test classes added in the same place in test_mac_image_check.py, both kept, and image-builder/test/all passes. The generator itself is unchanged, so your run still applies to this head.

Still untested, as you noted: a disk with two installs or a leftover ESP, and a full boot with this exact generator installed. The M4 Max (J616c) boots with an earlier revision of it from its own image, which mounts /boot/efi and /boot from the device-tree ESP the same way, but that is not this file; the two-install case is only covered by the test's fixtures.

@greptile-apps

greptile-apps Bot commented Dec 1, 2026 •

Copy link
Copy Markdown

Confidence Score: 5/5 · The PR appears safe to merge, with no actionable issues found.RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge, with no actionable issues found.

Summary

The PR installs omarchy-esp-generator to select /boot/efi from the ESP named by the Mac’s device tree. It selects /boot from the next partition on that disk when the filesystem matches the image’s Boot UUID.

  • Systemd mounts each Mac's own EFI and Boot partitions.

No actionable issues were found. Tests were inspected but not run during this review. allanclempe explicitly leaves non-PARTUUID device-tree properties and ambiguous partition matches to fstab.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Read device-tree ESP property] --> B{One valid PARTUUID?}
  B -->|No| C[Leave both mounts to fstab]
  B -->|Yes| D[Generate boot-efi.mount]
  D --> E{Find one matching ESP in sysfs?}
  E -->|No| F[Leave boot.mount to fstab]
  E -->|Yes| G[Find next partition by start sector]
  G --> H{ext4 magic and Boot UUID match?}
  H -->|No| F
  H -->|Yes| I[Generate boot.mount]
Loading

Reviews (1) · Last reviewed commit: "Mount /boot/efi and /boot from the ESP t..." · Reviewed by Greptile

This branch has not been deployed

No deployments
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.

Every image gives /boot and the ESP the same filesystem IDs; with two installs on one disk, fstab can mount the other install's partitions

2 participants