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

Fix 'Call to Hibernate failed: No such file or directory' with a swapfile in /home

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

The ProtectHome=yes diagnosis is a genuine, well-known logind gotcha and the Btrfs path is correct (btrfs filesystem mkswapfile -s SIZE file is real per btrfs-filesystem.8, which also states "A swapfile must be created in a specific way: NOCOW and preallocated"). The ext4/XFS path is the weak spot: fallocate creates unwritten/preallocated extents, and on XFS swapon rejects the resulting file ("swapfile has holes"). The modern, filesystem-agnostic way is mkswap --size --file, which allocates correctly. The record also never adds the fstab entry for the ext4/XFS case, so the swapfile disappears on reboot.

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

Deleting the old swapfile while it is still referenced in /etc/fstab leaves a boot that waits on a missing swap unit. Remove or update the fstab line in the same change.

Symptom

systemctl hibernate fails instantly with Call to Hibernate failed: No such file or directory, even though swapon --show clearly lists my swapfile and it is bigger than RAM.

Cause

systemd-logind runs with ProtectHome=yes, so it cannot see files under /home, /root or /run/user. Its pre-hibernation swap-size check therefore fails to stat the swapfile and reports ENOENT.

Fix


sudo swapoff /home/$USER/swapfile
sudo rm /home/$USER/swapfile

Recreate at the top level. Use mkswap --size --file rather than fallocate, because fallocate produces unwritten extents that swapon refuses on XFS:


sudo mkswap -U clear --size 32G --file /swapfile
sudo chmod 0600 /swapfile
sudo swapon /swapfile

(On older util-linux without --file, use dd if=/dev/zero of=/swapfile bs=1M count=32768 status=progress, then chmod 600, mkswap, swapon. Do not use fallocate.)

On Btrfs, use a NOCOW subvolume, as Omarchy does:


sudo btrfs subvolume create /swap
sudo chattr +C /swap
sudo btrfs filesystem mkswapfile -s 32g /swap/swapfile
sudo swapon -p 0 /swap/swapfile

Add to /etc/fstab in BOTH cases, or it is gone after reboot:


/swapfile      none swap defaults      0 0
# or, Btrfs:
/swap/swapfile none swap defaults,pri=0 0 0

Then redo resume= / resume_offset= for the new file (see the resume-offset record) and rebuild the initramfs. Sanity-check with swapon --show and systemctl hibernate.

Verify

systemctl hibernate no longer errors out immediately. swapon --show lists the new path and findmnt -no UUID -T /swap/swapfile resolves the backing device.

Sources

hibernate-swapfile-under-home-logind-error