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

Fix hibernation that returns straight to the desktop (not enough free swap)

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

Checked the cause against the Arch wiki raw wikitext for Power management/Suspend and hibernate, which states that the suspend image cannot span multiple swap partitions or swap files and that a Failed to put system to sleep. System resumed again line means not enough free swap was available, so the cause and the symptom hold on plain Arch and on Omarchy 4. The /etc/tmpfiles.d/hibernation_image_size.conf snippet is verbatim from that page and does not collide with the /etc/tmpfiles.d/omarchy-zswap.conf that omarchy-settings 4.0.2-1 ships on this machine. Read /usr/share/omarchy/bin/omarchy-hibernation-setup and omarchy-hibernation-available here: the setup script does create a Btrfs /swap subvolume with a swapfile sized to MemTotal, as the record says. Two defects in the Omarchy paragraph. First, omarchy-hibernation-available also requires /etc/mkinitcpio.conf.d/omarchy_resume.conf to exist, not only that the non-zram swap sum exceeds /sys/power/image_size, so the record's advice to grow swap by hand leaves the Hibernate menu entry hidden and the record never says so. Second, the Omarchy 4 documented entry point is omarchy hibernation setup, confirmed with omarchy hibernation --help on this workstation and in manual/36-system-sleep.md on the quattro branch, not the bare script name the record gives. I also replaced the invented /dev/mapper/extra-swap in the swapoff example with a real device taken from swapon --show, and added that Omarchy 4 runs zram at swap-priority 100 while the hibernation swapfile gets pri=0, which makes the multiple-swap consolidation case rare on a stock Omarchy machine. Confirmed on this workstation: /proc/swaps shows /swap/swapfile at priority 0 and /dev/zram0 at priority 100, and /sys/power/image_size is 13351321600 against a MemTotal of 32784988 kB. NOT exercised: I did not run systemctl hibernate or change any power state, so the resume path itself is unverified here, and this machine is a desktop, so no laptop-only behaviour was tested.

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

Growing swap consumes disk equal to RAM (Omarchy warns: 32 GB RAM means 32 GB of free space on the boot drive). Running swapoff on a busy system can OOM-kill processes if there is not enough free RAM to absorb the swapped-out pages.

Symptom

systemctl hibernate blanks the screen for a moment and then I am back at my desktop. The journal has Failed to put system to sleep. System resumed again and the kernel logged:


PM: hibernation: Normal pages needed: 999287 + 1024, available pages: 916116
PM: hibernation: Not enough free memory
PM: hibernation: Error -12 creating image

Cause

The hibernation image must fit entirely inside a **single** swap space, and it needs that much *free* swap at the moment of hibernating. Swap smaller than the working set, or free space spread across several swap devices, makes the kernel abort image creation with -ENOMEM.

Fix

Check what you have:


swapon --show
free -h
cat /sys/power/image_size

Either grow one swap space, or shrink the image. To shrink it persistently, on plain Arch and on Omarchy 4 alike:


sudo tee /etc/tmpfiles.d/hibernation_image_size.conf <<'EOF'
#    Path                   Mode UID  GID  Age Argument
w    /sys/power/image_size  -    -    -    -   0
EOF
sudo systemd-tmpfiles --create

0 asks the kernel to make the image as small as it can. Test immediately, before committing to the tmpfiles snippet:


echo 0 | sudo tee /sys/power/image_size
systemctl hibernate

If swapon --show lists more than one non-zram swap, free space cannot be pooled. Give them different priorities so one stays mostly empty, or temporarily switch one off so usage consolidates. Take the real device name from swapon --show, for example:


sudo swapoff /dev/nvme0n1p3
systemctl hibernate

**On Omarchy 4** do not build the swapfile by hand. The documented entry point is:


omarchy hibernation setup

(the underlying script is /usr/share/omarchy/bin/omarchy-hibernation-setup, and omarchy hibernation remove undoes it). It creates a Btrfs /swap subvolume with chattr +C, makes /swap/swapfile sized to MemTotal with btrfs filesystem mkswapfile, adds it to /etc/fstab at pri=0, writes HOOKS+=(resume) into /etc/mkinitcpio.conf.d/omarchy_resume.conf and resume=/resume_offset= into /etc/limine-entry-tool.d/resume.conf, then rebuilds the UKI with limine-mkinitcpio. It needs the default Limine bootloader and refuses otherwise.

The Hibernate entry in the Omarchy menu is guarded by omarchy-hibernation-available, and that script tests **two** conditions, not one:


# /usr/share/omarchy/bin/omarchy-hibernation-available
SWAPSIZE_KB=$(awk '!/Filename|zram/ {sum += $3} END {print sum+0}' /proc/swaps)
SWAPSIZE=$(( 1024 * ${SWAPSIZE_KB:-0} ))
HIBERNATION_IMAGE_SIZE=$(cat /sys/power/image_size)

if (( SWAPSIZE > HIBERNATION_IMAGE_SIZE )) && [[ -f /etc/mkinitcpio.conf.d/omarchy_resume.conf ]]; then

So growing swap on its own is not enough on Omarchy. Without /etc/mkinitcpio.conf.d/omarchy_resume.conf the Hibernate entry stays hidden however much swap you add, which is why omarchy hibernation setup is the route rather than a hand-rolled swapfile.

One Omarchy 4 detail that makes the multiple-swap case rare here: the shipped zram device runs at swap-priority = 100 and the hibernation swapfile at pri=0, so the swapfile normally stays empty, and omarchy-hibernation-available excludes zram from its sum anyway. Check with:


cat /proc/swaps

Verify

systemctl hibernate powers the machine fully off, and after power-on your session comes back with all applications where you left them. journalctl -b -1 | grep 'hibernation:' shows no Error -12.

Sources

hibernate-not-enough-free-swap