Skip to content

omarchy-mac-boot: let a kernel downgrade pass update-verify on Macs with a device tree overlay - #141

Open
only21mil wants to merge 1 commit into
omacom:mainfrom
only21mil:retire-saved-modules-no-overlays
Open

only21mil wants to merge 1 commit into
omacom:mainfrom
only21mil:retire-saved-modules-no-overlays

Conversation

@only21mil

@only21mil only21mil commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

Problem

After a kernel downgrade, 11-omarchy-mac-saved-modules.hook moves the running kernel's saved modules to /usr/lib/modules/.old so m1n1 gets the installed kernel's device trees, unless /etc/default/update-m1n1 sets DTBS or M1N1_UPDATE_DISABLED.

It read that file with the overlay call live, so a package-owned overlay that applies, such as omarchy-ane's, kept the modules and update-verify refused the reboot.

Change

The hook reads it with OMARCHY_DTB_OVERLAYS=0, the switch lib/dtb-overlays.sh documents, so only a DTBS the configuration sets itself stops it.

Verification

An AI agent ran every check; at each cold boot a person states they pressed power and typed the disk password.

Setup. Apple M1 test Mac (t8103), Omarchy stable, kernel 7.2.11.aurora14-1, a test overlay package (details below).

Steps. Install the package → downgrade linux-aurora to 7.2.11.aurora13-1 → update-verify → if it passes, power off and cold boot.

Before, 28abebe:

(2/8) Checking for a kernel downgrade's saved modules...
(3/8) Arming ConditionNeedsUpdate...
Apple Silicon boot check: device tree /lib/modules/7.2.11-14-1-ARCH/dtbs/s5l8960x-j71.dtb is not one of linux-aurora 7.2.11-13-1-ARCH's

This Mac might not boot what the update installed, so do not reboot yet.
update-verify exit 1

After, fcaeb5d merged with main, then its cold boot:

(2/8) Checking for a kernel downgrade's saved modules...
Moving the running kernel's saved modules (7.2.11-14-1-ARCH) to /usr/lib/modules/.old, as linux-modules-cleanup does at boot, so m1n1 carries the device trees of 7.2.11-13-1-ARCH. Reboot soon: until then the running kernel cannot load modules it has not loaded yet.
Apple Silicon boot check: installed linux-aurora 7.2.11-13-1-ARCH boot files match; running 7.2.11-14-1-ARCH, reboot pending
update-verify exit 0
test overlay property: 2cd1ae78
full check (no pending reboot): exit 0: Apple Silicon boot check: running linux-aurora 7.2.11-13-1-ARCH; installed boot files match

Re-check on main 95b0dd9: main plus the new test fails; 4597f0f (fcaeb5d re-signed, same tree) and its merge pass; test/integration/all 59 ok.

Links. regression test, #3, #13.

Not shown

  • A boot from different device trees: kernels 13 and 14 ship identical ones.
  • Disposable boot tests (not reached).
  • Not covered: a configuration that re-enables overlays before their call; the hook then keeps the modules and update-verify still refuses the reboot.

Prior PRs

None make this fix. maralcbr's #3 added the overlays and the switch; joshuaswarren's open #13 keeps it and leaves this hook alone.

Unedited full runs and detail

The Mac run. No shipped overlay applies on the test Mac, so the run installed a test package that ships one overlay through the same /usr/lib/omarchy-mac-boot/dtb-overlays path. It differs from a real one in one thing: it adds an inert root property instead of hardware nodes. It is not omarchy-ane. Kernel 7.2.11.aurora13-1 is an older edge build used only as a downgrade target.

  • The released package's hook is main's (the same script sha256 in both).
  • Before: omarchy-mac-boot 20261109-1, built from main 28abebe. After: 20261114-2, built from fcaeb5d merged with main 28abebe (tree 339dd8e). The two packages differ only by this change and the recorded source revision.
  • Overlay probe with the overlay installed on kernel 14, before either run: reading the configuration as main does gives a DTBS that includes /run/omarchy-dtb-overlays/t8103-*.dtb copies; reading it with OMARCHY_DTB_OVERLAYS=0 gives []. Both boot checks passed, and a cold boot on kernel 14 came up with the test property.
  • In the before run's transaction, nothing printed between the two hook lines quoted above. Its module state afterwards:
/usr/lib/modules/7.2.11-13-1-ARCH  vmlinuz-owner: linux-aurora
/usr/lib/modules/7.2.11-14-1-ARCH  vmlinuz-owner: error: No package owns /usr/lib/modules/7.2.11-14-1-ARCH/vmlinuz
boot-chain (pending reboot allowed): exit 1: Apple Silicon boot check: device tree /lib/modules/7.2.11-14-1-ARCH/dtbs/s5l8960x-j71.dtb is not one of linux-aurora 7.2.11-13-1-ARCH's
  • Before had no cold boot: that state was repaired before any power-off (the saved tree copied to .old, then removed, then update-m1n1). The kernel then went back to 14 with both boot checks passing and the same boot.bin as the earlier cold boot. The after run's module state:
/usr/lib/modules/7.2.11-13-1-ARCH  vmlinuz-owner: linux-aurora
/usr/lib/modules/.old/7.2.11-14-1-ARCH  vmlinuz-owner: error: No package owns /usr/lib/modules/.old/7.2.11-14-1-ARCH/vmlinuz
boot-chain (pending reboot allowed): exit 0: Apple Silicon boot check: installed linux-aurora 7.2.11-13-1-ARCH boot files match; running 7.2.11-14-1-ARCH, reboot pending
  • The new staged test fails on main 28abebe and passes on fcaeb5d and the merged tree (runs at the end).
  • CI on df02152, the merge of fcaeb5d into 28abebe: four green checks, the new test's cases ok, test/integration/all 59 ok.
  • CI on cf3bff2, the merge of 4597f0f into 95b0dd9: four green checks.
  • Cold boots: each started from a requested power-off (The system will power off now! in the previous boot's journal), after which the person at the Mac states they pressed the power button and typed the disk password. The disk's only unlock is one passphrase keyslot (no token, no network unlock in the initramfs), and each boot's journal shows the passphrase prompt before the unlock. The after run's boot came up on 7.2.11-13-1-ARCH with no failed units, and SSH returned on its own. The Mac then went back to the released package and kernel 14. Its first boot there is not counted (its timing could not be tied to the press); a repeat cold boot passed both boot checks; its kernel started 77–79 s after the previous boot's journal ended.
  • Each block above holds whole lines from the run's captures, unedited; the update-verify blocks start below its coloured heading line, Verify the Apple Silicon boot files.

Staged test (fixture root, stubbed tools): regression cover, not a Mac run.

  • The staged test builds a fake root with the packaged /etc/default/update-m1n1, pointed at the package's real lib/dtb-overlays.sh, and one overlay that applies to the running kernel's t6000 device tree. uname, pacman, rsync, dtc, fdtoverlay and fdtget are stubs. update-m1n1's pacman hook is a test function that builds boot.bin from the newest -ARCH tree. update-verify is the package's own entrypoint, run against the fixture root.
  • The test first checks that the staged configuration really sets DTBS from the overlay, so the new cases cannot pass on an overlay that does nothing. It checks that reading the configuration writes nothing to /run/omarchy-dtb-overlays, and that an owner's DTBS or M1N1_UPDATE_DISABLED still stops the hook: set after the overlays, on the line that sets the switch, or in a branch on sourcing the library.
  • A matrix of 44 configuration forms, run on d1babd2 (its hook and test are fcaeb5d's) against this library and Merge the device tree overlays over whatever DTBS update-m1n1 builds from #13's at 2ebcfd3 with overlays installed and not, found no case where the fix is wrong and main's hook is right; every form it still gets wrong sets or unsets OMARCHY_DTB_OVERLAYS itself.
  • omarchy-mac-boot/test/all (runtime at omacom/omarchy 81fd2d2, sh as bash, as in CI's Arch container): 266 ok on main 28abebe, 268 on fcaeb5d and 269 on the merged tree, 0 not ok. The candidate's base lacks main's fail-reason-test.sh. Run from a copy of the package directory alone, with no runtime: 268 ok on fcaeb5d, with 1 skip that needs the runtime.
  • On x86_64 Ubuntu 26.04, whose sh is dash, each suite file run on its own gives the same result on main 28abebe, fcaeb5d and the merged tree. Only update-m1n1-locale-test.sh fails, on all three, because sh is dash (omarchy-mac-boot: run the update-m1n1 locale test under bash, as on a Mac #117). Run whole with dash sh, test/all on fcaeb5d stops at that file, exit 1.
  • shellcheck -S warning on fcaeb5d: the hook is clean, and the test has only the three SC2154 warnings main's copy has. check-scope, check-architecture-gates and check-fixture-drift exit 0. check-fixture-drift warns that upstream's fixture copies of two drop-ins differ; this change touches no drop-in.
  • No integration test runs the hook, and nothing the runtime reads changes; test/integration/all still ran (above and below). Not reached: OMARCHY_DISPOSABLE_BOOT_TESTS=1 builds initramfs images and loop-device disks, which this change does not touch.
  • Re-check on main 95b0dd9, sh as bash, runtime at main's pin omacom/omarchy 2fca7fe: mac-saved-modules-test.sh on main with only the new test added stops at the first new case, exit 1 (same output as on 28abebe); 9 ok on 4597f0f and on its merge with 95b0dd9 (tree 09f8096). On the merge, omarchy-mac-boot/test/all 284 ok and test/integration/all 59 ok, 0 not ok; check-scope, check-architecture-gates, check-version-bump and check-fixture-drift exit 0 (the same drift warning); shellcheck shows main's three SC2154 warnings only. On 4597f0f with runtime 81fd2d2: 268 ok and 59 ok.
  • Merge the device tree overlays over whatever DTBS update-m1n1 builds from #13 at 2ebcfd3: a three-way merge of its omarchy-mac-boot/README.md with fcaeb5d's has no conflicts, so either can merge first.
  • scottjones's Leave overlays out of the boot check when update-m1n1's configuration does #10 and Test an administrator's DTBS with the overlay call still in place #11 handled overlays in the boot check, not this hook.
  • Scope: no issue exists. omarchy-mac-boot is versioned by date, so nothing is bumped. No manual page describes this hook; the package README says beside it how the hook reads the configuration.

Before, main 28abebe with only the new test added:

$ bash omarchy-mac-boot/test/mac-saved-modules-test.sh   # main 28abebe, only the new test added
ok - the hook runs right after kernel-modules-hook's restore, before anything reads /usr/lib/modules
ok - a downgrade's saved modules give m1n1 the wrong device trees, which update-verify refuses
ok - the hook moves a downgrade's saved modules to .old before m1n1 is rebuilt, leaving no stale module tree, and update-verify passes
ok - an upgrade, a reinstall, an owned or intervening tree (said why), no kernel-modules-hook, or DTBS not from the -ARCH default moves nothing
ok - with an overlay that applies, an owner's DTBS still leaves the saved modules alone
not ok - a downgrade's saved modules move to .old when only a package-owned overlay sets DTBS
status 0: 6.17.0-aurora1-ARCH
6.18.0-aurora2-ARCH
exit=1

After, fcaeb5d:

$ bash omarchy-mac-boot/test/mac-saved-modules-test.sh   # fcaeb5d
ok - the hook runs right after kernel-modules-hook's restore, before anything reads /usr/lib/modules
ok - a downgrade's saved modules give m1n1 the wrong device trees, which update-verify refuses
ok - the hook moves a downgrade's saved modules to .old before m1n1 is rebuilt, leaving no stale module tree, and update-verify passes
ok - an upgrade, a reinstall, an owned or intervening tree (said why), no kernel-modules-hook, or DTBS not from the -ARCH default moves nothing
ok - with an overlay that applies, an owner's DTBS still leaves the saved modules alone
ok - an overlay that applies is not an owner's DTBS: the hook reads the configuration without building overlays and retires the saved modules
ok - with an overlay that applies, the owner's settings stop the hook beside the switch and after the library
ok - a failed copy removes nothing
ok - only an unprivileged caller can point the script at another root
exit=0

Merged tree, fcaeb5d merged with main 28abebe:

$ bash omarchy-mac-boot/test/mac-saved-modules-test.sh   # fcaeb5d merged with main 28abebe (tree 339dd8e)
ok - the hook runs right after kernel-modules-hook's restore, before anything reads /usr/lib/modules
ok - a downgrade's saved modules give m1n1 the wrong device trees, which update-verify refuses
ok - the hook moves a downgrade's saved modules to .old before m1n1 is rebuilt, leaving no stale module tree, and update-verify passes
ok - an upgrade, a reinstall, an owned or intervening tree (said why), no kernel-modules-hook, or DTBS not from the -ARCH default moves nothing
ok - with an overlay that applies, an owner's DTBS still leaves the saved modules alone
ok - an overlay that applies is not an owner's DTBS: the hook reads the configuration without building overlays and retires the saved modules
ok - with an overlay that applies, the owner's settings stop the hook beside the switch and after the library
ok - a failed copy removes nothing
ok - only an unprivileged caller can point the script at another root
exit=0

Generated with Claude Opus 5.5 in T3 Code Nightly

@scottjones scottjones left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks right to me. The hook now reads /etc/default/update-m1n1 with OMARCHY_DTB_OVERLAYS=0 (omarchy-mac-boot/files/usr/share/libalpm/scripts/omarchy-mac-retire-saved-modules:46), the same way the boot check already reads it (omarchy-mac-boot/bin/omarchy-apple-silicon-boot-check:606). An overlay's DTBS is built from the newest -ARCH tree, so it is still the default and shouldn't stop the hook. After the move, update-m1n1 runs later in the transaction with overlays live and picks the installed kernel's trees. The boot check rebuilds the same image with dtb_overlays_apply, so the two still agree.

On failure paths: an owner's own DTBS or M1N1_UPDATE_DISABLED still stops the hook. A config that turns overlays back on just keeps the old behaviour (modules kept, update-verify refuses the reboot), which is safe. Reading the config with overlays off also stops the hook from writing /run/omarchy-dtb-overlays. No version bump.

One small gap, not blocking: the staged test checks that the hook retires the modules when an overlay applies (omarchy-mac-boot/test/mac-saved-modules-test.sh:231), but it doesn't run update-m1n1 and update-verify afterwards with the overlay live. Only the Mac run covers that. A follow-up case that does would pin the "boot check agrees" part.

What I ran (PR merged onto main 1a865a9, x86_64 host, runtime pinned at 2fca7fe0):

  • omarchy-mac-boot/test/mac-saved-modules-test.sh: 9 ok.
  • omarchy-mac-boot/test/all: 283 ok, 0 not ok. test/integration/all: 59 ok.
  • check-scope, check-architecture-gates: exit 0.
  • Mutations, each reverted:
    • Dropping OMARCHY_DTB_OVERLAYS=0 fails "a downgrade's saved modules move to .old when only a package-owned overlay sets DTBS".
    • Ignoring the owner's DTBS fails "DTBS set in /etc/default/update-m1n1 is left alone".
    • Ignoring M1N1_UPDATE_DISABLED fails "m1n1 left to its owner is left alone".

…ys when retiring saved modules

11-omarchy-mac-saved-modules.hook retires the running kernel's saved
modules after a downgrade only when update-m1n1 takes its device trees
from the -ARCH default, so it reads /etc/default/update-m1n1 and stops
when that sets DTBS. It read the file with the overlay call live. On a
Mac with a package-owned overlay that applies, such as omarchy-ane, the
call sets DTBS to the overlaid copies and writes them to
/run/omarchy-dtb-overlays, so the hook took that for an owner's DTBS and
kept the saved modules. update-m1n1 then built boot.bin from the running
kernel's device trees, and update-verify refused the reboot.

Read the configuration with OMARCHY_DTB_OVERLAYS=0, the switch
dtb-overlays.sh offers for reading it without building anything, so only
a DTBS the configuration sets itself counts. A configuration that
re-enables overlays before their call can override this switch. If that
call leaves DTBS set, the hook keeps the modules as before, and
update-verify still refuses the reboot. The README says both beside the
hook. The test stages the packaged
configuration with an overlay that applies, and checks that an owner's
DTBS or M1N1_UPDATE_DISABLED still stops the hook, set after the
overlays, beside the switch, or in a branch on sourcing the library.
@only21mil
only21mil force-pushed the retire-saved-modules-no-overlays branch from fcaeb5d to 4597f0f Compare November 21, 2026 03:51
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.

2 participants