OPINIONATED OMARCHY
TROUBLESHOOTING CORPUS
790
RECORDS
790
AUDITED
0
UNCHECKED
2388
SOURCES
LIVE
power-suspend high common DISPUTE

Get the right resume_offset for a Btrfs swapfile (filefrag lies)

archomarchyendeavouroscachyosmanjarobtrfsliminegrub
CORRECTED An auditor found the fix wrong or incomplete and rewrote it.
AUDIT NOTE

The Btrfs diagnosis is exactly right and sudo btrfs inspect-internal map-swapfile -r is what omarchy-hibernation-setup itself uses (RESUME_OFFSET=$(sudo btrfs inspect-internal map-swapfile -r "$SWAP_FILE")). The Limine drop-in commands match the real script. But the no-reboot test at the end has the two sysfs writes in the WRONG ORDER: writing to /sys/power/resume triggers the resume attempt immediately, so it must be written last, after resume_offset. As printed, the offset is applied to a resume that has already been attempted with offset 0. The test appears to fail even when the values are right, and on a machine with a stale image it can attempt a resume from the wrong blocks.

The cause above was not rewritten and may still contain the error described. The fix below is the corrected version.
RISK

A wrong resume_offset points the kernel at arbitrary blocks on the swap device. It normally just fails to resume, but never point resume= at a partition that is not actually swap. That risks writing the hibernation image over a filesystem.

Symptom

Hibernation writes the image and powers off, but the machine always boots fresh. I got resume_offset from filefrag -v as every guide says. Or the Omarchy setup left resume_offset=" empty in /etc/limine-entry-tool.d/resume.conf.

Cause

On Btrfs, filefrag's physical_offset is an address in Btrfs's virtual address space, not the real on-disk offset, because Btrfs supports multiple devices. The kernel resume code needs the true physical offset, so a filefrag-derived value silently points at the wrong blocks.

Fix

Everything above the no-reboot test is correct. Replace only that block. Note that resume_offset MUST be written before resume, because the write to /sys/power/resume is what triggers the resume attempt:


# offset FIRST
echo 198122980 | sudo tee /sys/power/resume_offset
# device LAST - this write triggers the resume attempt
lsblk -o NAME,MAJ:MIN,SIZE   # e.g. nvme0n1p2 -> 259:2
echo 259:2 | sudo tee /sys/power/resume

Also worth adding: btrfs inspect-internal map-swapfile only produces a usable offset on a single-device Btrfs filesystem. Hibernation to a swapfile on a multi-device Btrfs volume is not supported by the kernel at all. Check with sudo btrfs filesystem show before spending time on the offset.

And verify the result actually reached the kernel after rebuilding:


cat /proc/cmdline | tr ' ' '\n' | grep -E 'resume'

Verify

cat /proc/cmdline shows both resume= and a non-empty resume_offset=, and a hibernate/power-on cycle restores the session.

Sources

hibernate-btrfs-swapfile-wrong-resume-offset