Skip to content

Skip empty resume device in hibernation setup - #13908

Open
AnPod wants to merge 8 commits into
omacom:quattrofrom
AnPod:fix/hibernation-empty-resume-device
Open

AnPod wants to merge 8 commits into
omacom:quattrofrom
AnPod:fix/hibernation-empty-resume-device

Conversation

@AnPod

@AnPod AnPod commented Sep 30, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes #12630: omarchy-hibernation-setup could write resume= with an empty device when findmnt returned nothing, which produces a broken kernel command line.

Changes

  • Only write the limine drop-in when both the resume device and the resume offset are known. Each missing value gets its own warning.
  • If an existing drop-in already has an empty resume= in its active KERNEL_CMDLINE[default] assignment, fill it in when findmnt now finds the device, and rebuild (unless --no-rebuild). Comments that contain resume= are left alone.
  • Add test/shell.d/hibernation-setup-test.sh, which runs a copy of the script against a fixture with stubbed sudo, findmnt and btrfs.

Testing

  • test/shell.d/hibernation-setup-test.sh (8 cases), bash -n and shellcheck on both files
  • Not run on real hardware or a real btrfs swapfile with limine; only stubs.
  • test/shell.d/unowned-system-paths-test.sh could not run here because the omarchy-pkgs checkout is not available.

@greptile-apps

greptile-apps Bot commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 4/5

[High impact] Modifies hibernation setup and resume device configuration.

The PR is not ready to merge because an empty unquoted resume parameter can remain broken after setup retries.

Findings

  1. P1 Empty unquoted parameters remain broken ▶

Summary

The PR avoids writing an empty resume device, makes missing resume configuration retryable, and adds fixture-based setup tests.

  • The latest change avoids appending parameters when an unquoted assignment already contains them.
  • That presence check also prevents repair of empty unquoted parameters.

Reviews (6) · Last reviewed commit: "Ignore trailing comments when deciding a..." · Reviewed by Greptile

Comment thread bin/omarchy-hibernation-setup Resolved
Comment thread bin/omarchy-hibernation-setup Resolved
AnPod added a commit to AnPod/omarchy that referenced this pull request Oct 1, 2026
Greptile P1/P2 on omacom#13908: if the first run wrote the HOOKS marker
but skipped resume.conf (empty findmnt), later runs now create or
repair incomplete/empty resume tokens and rebuild initramfs once.
@jandrusk

jandrusk commented Oct 1, 2026

Copy link
Copy Markdown

Nice fix for #12630, and the fixture tests are thorough.

Nit: RESUME_OFFSET is interpolated into sed / the drop-in without a digits-only check ([[ $RESUME_OFFSET =~ ^[0-9]+$ ]]). Same for RESUME_DEVICE on the append path (MISSING_RESUME_PARAMS) — the sed repair escapes &|\ but the append/tee path does not validate /dev/... shape. Pre-existing pattern, but this PR is the right place to tighten both before writing kernel cmdline.

Comment thread bin/omarchy-hibernation-setup Resolved
AnPod and others added 4 commits October 3, 2026 07:17
Greptile P1/P2 on omacom#13908: if the first run wrote the HOOKS marker
but skipped resume.conf (empty findmnt), later runs now create or
repair incomplete/empty resume tokens and rebuild initramfs once.
Reject non-digit RESUME_OFFSET and non-/dev RESUME_DEVICE on create, repair, and append paths.
Greptile: device-mapper paths like /dev/mapper/crypt@home were rejected.
Accept @ in the resume device regex on create and repair paths, cover it
in tests, and keep missing-drop-in retry / single-rebuild behavior intact.
omarchybot and others added 4 commits October 15, 2026 05:25
quattro added its own test/shell.d/hibernation-setup-test.sh (the locale-safe memory prompt check, omacom#14520), which collided with this branch's new test of the same name. Keep quattro's file as it is and move this branch's fixture test to hibernation-resume-setup-test.sh: the two test different things, and quattro's skips the whole file on a host without /sys/power/image_size, which would have skipped the fixture tests too.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
quattro's setup now skips itself on Apple Silicon before doing anything, and the fixture test let the real detector answer, so on an Asahi host every case failed at its first assertion. Answer no in the fixture, as the test already does for omarchy-cmd-missing.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Codex Medium <noreply@openai.com>
The append path decided a parameter was missing from patterns that only recognise the double-quoted form, but Limine also accepts unquoted command lines. A working drop-in such as KERNEL_CMDLINE[default]=quiet resume=/dev/mapper/other resume_offset=6789 would get a second resume= and resume_offset= for /swap/swapfile appended and the UKI rebuilt, overriding a configuration quattro left alone. Append each one only when no active KERNEL_CMDLINE line mentions it in any form.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Codex Medium <noreply@openai.com>
The append guard matched resume= anywhere on an active line, so a trailing comment such as "# previously resume=/dev/old" counted as a configured device and the missing parameter was never added. Stop the match at the first #.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Codex Medium <noreply@openai.com>
@omarchybot omarchybot added the verified Omarchy Triage has verified that this issue is ready for final review label Oct 15, 2026
RESUME_CHANGED=true
fi
# Append only when no active line sets it in any form, quoted or not.
elif ! grep -Eq '^[[:space:]]*KERNEL_CMDLINE\[default\]\+?=([^#]*[[:space:]"])?resume=' "$RESUME_DROP_IN"; then

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P1 Empty unquoted parameters remain broken

If an existing drop-in has an unquoted assignment with an empty resume=, this check treats the parameter as already set. The repair above only handles quoted assignments, so setup neither fills in the device nor appends a usable value. Hibernation resume remains broken after a retry. The same problem applies to an empty unquoted resume_offset= at line 123.

Knowledge Base Used: Pin root before the Quattro package transaction

@omarchybot omarchybot added the ready Good to merge label Oct 15, 2026
@omarchybot

Copy link
Copy Markdown
Collaborator

Reviewed at 5644c6d against quattro (c582e1d) by Claude Opus 5.5, with a second opinion from Codex Medium over three rounds. The bug in #12630 is real, this fixes it, and nothing is left open.

What ran. Everything ran on a disposable Omarchy VM. A reproduction written separately from the test here ran a path-redirected copy of the script with findmnt returning nothing, then with it working again, and against the drop-in quoted in #12630 (resume= resume_offset=9338098). On quattro, and with this change reverted, all five checks fail: setup writes resume= empty, a re-run leaves it, and the existing broken drop-in is never repaired. At this head all five pass: nothing is written while the device is unknown, the next run writes resume=/dev/mapper/root, the broken drop-in is filled in, and the UKI is rebuilt once. ./test/cli, hibernation-resume-setup-test.sh (34 cases), hibernation-setup-test.sh, bin-style-test.sh and unowned-system-paths-test.sh all pass. The factory reset and the installer both run setup with --force --no-rebuild and fail on a non-zero exit. No new path here exits non-zero.

Pushed to this branch.

  • A merge of quattro, which had added an unrelated test/shell.d/hibernation-setup-test.sh (the locale-safe memory prompt check from Keep the hibernation prompt memory size locale-safe #14520) under the same name as the test here. That test stays as it is, and this branch's test moves to test/shell.d/hibernation-resume-setup-test.sh. Its skip on hosts without /sys/power/image_size would otherwise have skipped these cases too.
  • The test now stubs omarchy-hw-aarch64-apple. quattro's setup now exits early on Apple Silicon, so on an Asahi host every case failed at its first assertion. Codex found this.
  • bin/omarchy-hibernation-setup:110 and :123: a parameter is appended only when no active KERNEL_CMDLINE[default] line already sets it, quoted or not, ignoring anything after a #. Limine accepts unquoted command lines, so a working KERNEL_CMDLINE[default]=quiet resume=/dev/mapper/other resume_offset=6789 got a second resume= and resume_offset= appended and the UKI rebuilt. Codex found this, and both cases have a test.

Competing fixes. #9860 and #11477 also fix #12630. #9860 is the oldest, but it exits 1 when the device is unknown, which fails a factory reset. It also cannot repair a machine where the marker was written but the drop-in was not. #11477 rejects device names containing @ (/dev/mapper/crypt@home). It also refuses to touch a resume.conf holding anything beyond its own single line, a comment included, and exits 1 instead. This pull request handles both. Codex was asked which fix should win before this review gave its own answer, and chose this one for those reasons. #11477 also fixes the stale offset in #11437, which this does not, so the two will conflict if both land.

Waiting on the maintainer.

@omarchybot omarchybot removed ready Good to merge verified Omarchy Triage has verified that this issue is ready for final review labels Oct 26, 2026
@omarchybot

Copy link
Copy Markdown
Collaborator

Re-reviewed at 5644c6d against quattro (7eedd17) by Claude Opus 5.5, with a second opinion from Codex Medium. This changes what my earlier comment said: this pull request no longer merges, and an older open fix for #12630 should go first.

Conflict. quattro has since merged #16658, which names the resume device by filesystem UUID (resume=UUID=…) through a new resume_device() and renames old /dev/ entries on configured machines. This branch conflicts with it in bin/omarchy-hibernation-setup, and its ^/dev/ check on the device would reject the UUID= value that quattro now writes.

Competing fixes. Three open pull requests fix #12630: #9860, #11477 and this one. By default the oldest one wins, unless a newer one is clearly better.

When the device can be found and the rebuild succeeds, this and #11477 behave the same on the drop-in from #12630. This one also does two things #11477 doesn't: it repairs a hand-edited drop-in in place where #11477 refuses one, and it accepts @ in device names. Neither outweighs the rebuild defect, so #11477 should go first. Codex Medium came to the same conclusion on its own question; its independence is not guaranteed.

What ran. Nothing ran this round. Comparing the three fixes needed only the diffs and the code on quattro, and the worker run from the earlier review (at this head, against c582e1d) predates #16658. Nothing was pushed to this branch.

Waiting on: the maintainer, to choose between the fixes for #12630. #11477 also needs porting onto #16658 before it can land.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

omarchy-hibernation-setup can write an empty resume= device, and nothing detects or repairs it

3 participants