Skip to content

Hibernation: fail when unsupported; refuse empty resume= device - #9860

Closed
chessing234 wants to merge 6 commits into
omacom:quattrofrom
chessing234:fix/hibernation-setup-nonzero-exit
Closed

chessing234 wants to merge 6 commits into
omacom:quattrofrom
chessing234:fix/hibernation-setup-nonzero-exit

Conversation

@chessing234

@chessing234 chessing234 commented Sep 2, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Test plan

  • Existing hibernation checks still apply
  • bash test/shell.d/hibernation-empty-resume-test.sh

Fixes #12630

Unsupported kernels and missing Limine previously exited 0, so install
scripts treated a skipped setup as success. Return non-zero for those
hard failures; keep 0 for user cancel and already-configured.
@chessing234

Copy link
Copy Markdown
Contributor Author

@dhh @ryanrhughes ready for review

@chessing234 chessing234 changed the title Fail hibernation setup when the host cannot hibernate Hibernation: fail when unsupported; refuse empty resume= device Sep 21, 2026
@omarchybot omarchybot added the bug Something isn't working label Sep 27, 2026
@omarchybot

Copy link
Copy Markdown
Collaborator

Reviewed at 82249c8 against quattro (f45461a) by Claude Opus 5.5, with a second opinion from Codex Medium. The bug in #12630 is real, and this pull request fixes the case of a live machine re-running setup, but it has two defects. Two other open pull requests fix the same bug and handle both cases.

What ran. Everything ran on a disposable Omarchy VM with a btrfs root and hibernation configured. Setup ran in a snapshot chrooted the way omarchy-system-factory-reset does it, and on the live system with a planted resume= resume_offset=N drop-in. The new test and unowned-system-paths-test.sh pass. The one ./test/cli failure (the vscode theme check) fails on quattro alone too.

What was found.

  • bin/omarchy-hibernation-setup:113: the new exit 1 aborts a factory reset on any machine with hibernation set up. The reset runs setup in a chroot into a subvolume directory that is not a mount point, where findmnt -no SOURCE -T prints nothing. On quattro, that is where omarchy-hibernation-setup can write an empty resume= device, and nothing detects or repairs it #12630's resume= resume_offset=4084497 came from. With this change, setup exits 1 and omarchy-system-factory-reset:278 fails the reset. By then setup has already written HOOKS+=(resume), so the next run reports "already set up" without adding the parameters.
  • migrations/1789972000.sh:12: the migration deletes the broken drop-in but leaves HOOKS+=(resume) in place. The re-run it recommends then reports "Hibernation is already set up" and exits 0, so no drop-in is ever written again. Setup only repairs a drop-in that still exists. On the VM, the in-script repair rewrote the planted file to resume=/dev/vda2 resume_offset=1627847. After the migration, there was nothing left to repair.
  • The exit-status changes for unsupported machines and the missing Limine bootloader are outside what omarchy-hibernation-setup can write an empty resume= device, and nothing detects or repairs it #12630 asks for. Codex also noted that the new test only greps the source, so it would pass with both defects above in place.

Competing fixes. #13908 (an in-place repair) and #11477 (a full reconcile, which also covers the stale offsets in #11437) both refuse an empty device without aborting. They also write or repair the parameters when setup is re-run, including when the drop-in is missing. Neither resolves the device inside the factory-reset chroot, but neither fails the reset or strands the machine. Codex Medium agreed with both findings above; this review cannot show that it reached them independently.

Waiting on the maintainer to choose between the three fixes for #12630. Nothing was pushed to this branch.

@greptile-apps

greptile-apps Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Confidence Score: 3/5 · The PR is not ready to merge because both previous hibernation failures remain.RetriggerView in GreptileConfidence Score: 3/5

[Medium impact] The changes reach hibernation setup and the boot resume path.

The PR is not ready to merge because both previous hibernation failures remain.

Findings

  1. P1 Empty offsets skip device repair ▶
  2. P1 Reset leaves resume settings missing ▶

Summary

The PR rejects unsupported hibernation setup and prevents new drop-ins from containing an empty resume= device.

  • Unsupported hibernation prerequisites make setup exit with a failure status.
  • Existing empty resume entries are repaired when setup finds a stable device.
  • Fresh setup waits for a resume device before writing boot parameters.

Reviews (3) · Last reviewed commit: "Drop the source-grepping hibernation tes..." · Reviewed by Greptile

previous=$(<"$RESUME_DROP_IN")
[[ $previous =~ ^KERNEL_CMDLINE\[default\]\+=\"\ ?resume=(/dev/[^[:space:]\"]+)\ resume_offset=([0-9]+)\"$ ]] || return 0
[[ ${BASH_REMATCH[1]} != /dev/mapper/* ]] || return 0
[[ $previous =~ ^KERNEL_CMDLINE\[default\]\+=\"\ ?resume=(/dev/[^[:space:]\"]+)?\ resume_offset=([0-9]+)\"$ ]] || return 0

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 offsets skip device repair

If a legacy drop-in contains resume= resume_offset= and map-swapfile still fails, this regex returns success without repairing either value. The new migration matches that line, but setup exits successfully and the migration is marked complete. Fixing the mount later will not trigger another repair.

Detect the empty device independently of the offset and return non-zero until both values can be repaired. This also satisfies the migration rule that unfinished repairs must remain pending.

File Used: agents/skills/migrations.md (source)

omarchybot and others added 3 commits November 16, 2026 22:20
The factory reset runs setup in a chroot where findmnt finds no device for the swapfile, and fails the reset when setup exits non-zero, so exiting 1 there made a factory reset impossible on every machine with hibernation set up. Leave the drop-in out with a warning instead, as setup already did for an unknown offset, and still write the resume hook so omarchy-hibernation-remove can undo it. The already-set-up check now needs the drop-in, so a rerun on the booted system adds the parameters.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Codex Medium <noreply@openai.com>
omarchy-hibernation-remove leaves resume.conf behind. Without the resume hook, setup --force takes the fresh path, recreates the swapfile and its fstab entry, writes the hook and rebuilds, and keeps the broken drop-in. Require the hook, as migration 1792965062 does.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Codex Medium <noreply@openai.com>
Co-Authored-By: Muse Wonder High <noreply@meta.com>
It checked that the guard was spelled as written and tested the migration against a stub, both of which AGENTS.md rules out. hibernation-setup-test.sh runs the real setup through both cases.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Muse Wonder High <noreply@meta.com>
Comment on lines +223 to +229
# An empty device writes `resume= resume_offset=N`. The factory reset's chroot finds
# no device, so leave the drop-in out without failing; a rerun adds it.
if [[ -n $RESUME_DEVICE && -n $RESUME_OFFSET ]]; then
sudo mkdir -p /etc/limine-entry-tool.d
echo "KERNEL_CMDLINE[default]+=\" resume=$RESUME_DEVICE resume_offset=$RESUME_OFFSET\"" | sudo tee "$RESUME_DROP_IN" >/dev/null
else
echo "Warning: Could not determine resume offset for $SWAP_FILE" >&2
echo "Warning: Could not determine resume device and offset for $SWAP_FILE (device='$RESUME_DEVICE' offset='$RESUME_OFFSET'); re-run omarchy-hibernation-setup to add them" >&2

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 Reset leaves resume settings missing

When findmnt finds no device in the factory-reset chroot, setup now succeeds without writing resume.conf. The reset accepts that success and rebuilds the boot files, but no later step reruns setup to add the missing resume parameters.

Setup still writes omarchy_resume.conf, so omarchy-hibernation-available can offer Hibernate even though the boot files lack the parameters needed to restore the session. Determine the device before completing the reset, or arrange a required repair before hibernation becomes available.

@omarchybot omarchybot added the verified Omarchy Triage has verified that this issue is ready for final review label Nov 16, 2026
@omarchybot

Copy link
Copy Markdown
Collaborator

Re-reviewed at 6dd5097, the merge with quattro (3b36b9e), by Claude Opus 5.5, with second opinions from Codex Medium and muse-wonder (via pi, thinking high). Moving the hook after the drop-in and requiring the drop-in in the already-set-up check fixed the stranded state from the last review. Two defects remained, so I pushed three commits to the branch. It now fixes #12630 on a running machine, and I've linked it.

What ran. Everything ran on a disposable Omarchy VM with a btrfs root and hibernation set up.

  • With resume= resume_offset=N planted, quattro reports "Hibernation is already set up" and leaves it. This branch renames it to resume=UUID=… and rebuilds the boot image. Re-run with the commits below added, the migration makes the same repair.
  • In a snapshot chrooted the way omarchy-system-factory-reset does it, findmnt prints nothing. There, quattro writes resume= resume_offset=3417344, which is where omarchy-hibernation-setup can write an empty resume= device, and nothing detects or repairs it #12630's line comes from.
  • ./test/cli, hibernation-setup-test.sh and seven other hibernation and migration test files pass, and CI is green.

Pushed.

  • 51fb6b7: at 6dd5097, setup exited 1 inside that chroot, and the reset fails on any non-zero exit. That made a factory reset impossible on every machine with hibernation set up. Setup now warns, leaves the drop-in out (as it already did for an unknown offset), and still writes the hook. A later run then adds the parameters. A new case in hibernation-setup-test.sh fails on quattro and on 6dd5097.
  • 289a722: omarchy-hibernation-remove leaves resume.conf behind. On the VM, after a remove, the migration ran setup --force down the fresh path. It recreated the 3.8 GB swapfile and its fstab entry, wrote the hook back, rebuilt the boot image, kept the broken drop-in and exited 0. It now requires the resume hook first, as migrations/1792965062.sh does.
  • 1e8e35c: removes hibernation-empty-resume-test.sh. It grepped the source for the guard and tested the migration against a stub, and AGENTS.md rules out both. The cases in hibernation-setup-test.sh run the real setup instead. The test plan in the description still names the removed file.

Still open. Codex, muse-wonder and Greptile each point out the same thing: a factory reset now finishes, but its boot image carries no resume parameters, and nothing re-runs setup to add them. On quattro that image carries an empty resume=, so hibernation after a reset is broken either way. Fixing it means the reset naming the device from outside its chroot and handing it to setup, which is a change to omarchy-system-factory-reset. Both reviewers also note that the exit 0 → 1 change for hosts without /sys/power/image_size or limine-mkinitcpio goes beyond #12630. Through migrations/1792965062.sh and this one, such a machine would keep the migration pending and hold up every migration after it. Neither reviewer disputed the repair itself, and both agreed with the three commits; this review cannot show they reached that independently.

Competing fixes. #11477 and #13908 also fix #12630 and now conflict with quattro. Asked to choose among the three, Codex leaned towards #13908 and muse-wonder towards this one. #11477 and #13908 both write the kernel device name instead of the UUID that quattro now uses, #13908 does not check its rebuild, and neither repairs existing installs on update. This one is the oldest and now carries neither of the defects above.

Waiting on the maintainer: whether to keep the exit-code change, and how the factory reset should name the resume device.

@omarchybot omarchybot removed the verified Omarchy Triage has verified that this issue is ready for final review label Nov 24, 2026
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

2 participants