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

Enable hibernation on a system whose only swap is zram

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

Cause confirmed against the Arch wiki raw wikitext for Power management/Suspend and hibernate: hibernating to swap on zram is unsupported even with a backing device, and systemd always ignores zram block devices before triggering hibernation. The warning against an on-demand swap unit is on the same page, citing systemd issues 16708 and 30083, so it stays. The Btrfs branch of the fix matches /usr/share/omarchy/bin/omarchy-hibernation-setup on this machine step for step: /swap subvolume, chattr +C, btrfs filesystem mkswapfile -s at MemTotal, defaults,pri=0 in fstab, swapon -p 0. The defect is the zram configuration step. Omarchy 4 ships /usr/lib/systemd/zram-generator.conf.d/90-omarchy.conf from omarchy-settings 4.0.2-1 with zram-size = ram, compression-algorithm = zstd and swap-priority = 100, and zram-generator.conf(5) states that the main configuration file has the lowest precedence and is overridden by any drop-in, so writing /etc/systemd/zram-generator.conf as the record instructs changes nothing on Omarchy 4, and its zram-size = ram / 2 contradicts the ram Omarchy actually uses. Worse, /usr/share/omarchy/migrations/1785013000.sh deletes a stock-looking copy of that file on the next omarchy update and prints that local changes belong in /etc/systemd/zram-generator.conf.d/99-local.conf. I also corrected the symptom: the Hibernate entry is hidden, not greyed out, because /usr/share/omarchy/shell/plugins/menu/Menu.qml says guarded items are hidden when their when: evaluates false and omarchy-menu.jsonc guards system.hibernate with omarchy-hibernation-available, and the Omarchy 4 command is omarchy hibernation setup, confirmed with omarchy hibernation --help here and in manual/36-system-sleep.md on quattro. Confirmed on this workstation: /proc/swaps lists /dev/zram0 at priority 100 and /swap/swapfile at priority 0, exactly the shape the verify step describes. NOT exercised: I ran no systemctl hibernate, touched no zram or swap unit, and this machine is a desktop, so the record's laptop tag was not tested. applies_to lists laptop but not desktop even though the problem applies equally on a desktop, and the verdict schema has no field to correct that.

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

The swapfile consumes disk space equal to total RAM. Editing /etc/fstab incorrectly can leave the boot hanging on a swap unit that never appears.

Symptom

Omarchy or CachyOS style setup with zram. swapon --show lists only /dev/zram0, and hibernation is unavailable: on Omarchy 4 the Hibernate entry is missing from the Omarchy menu (Super + Esc), because the menu hides any item whose when: guard fails and system.hibernate is guarded by omarchy-hibernation-available. Run directly, systemctl hibernate fails and logind reports that there is not enough swap space.

Cause

zram lives in RAM, so it cannot hold a hibernation image. logind deliberately ignores zram block devices when sizing the hibernation target, and hibernating into zram is unsupported even with a backing device.

Fix

Keep zram for everyday swapping and add a **disk-backed** swap space at a *lower* priority for hibernation only.

**On Omarchy 4**, run the supported command and change nothing else:


omarchy hibernation setup

It creates the Btrfs /swap subvolume with chattr +C, makes /swap/swapfile sized to MemTotal with btrfs filesystem mkswapfile, appends /swap/swapfile none swap defaults,pri=0 0 0 to /etc/fstab, runs swapon -p 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 requires the default Limine bootloader.

Do **not** write /etc/systemd/zram-generator.conf on Omarchy 4. The priority you want is already set, in a vendor drop-in owned by omarchy-settings:


# /usr/lib/systemd/zram-generator.conf.d/90-omarchy.conf
[zram0]
zram-size = ram
compression-algorithm = zstd
swap-priority = 100

zram-generator.conf(5) says the main configuration file "is read before any of the configuration directories, and has the lowest precedence", so anything in /etc/systemd/zram-generator.conf is overridden by that drop-in and does nothing. Omarchy's own migration /usr/share/omarchy/migrations/1785013000.sh deletes a stock-looking copy of that file on the next omarchy update. If you do need a local change, put it in a later-sorting drop-in:


sudo mkdir -p /etc/systemd/zram-generator.conf.d
sudo tee /etc/systemd/zram-generator.conf.d/99-local.conf <<'EOF'
[zram0]
zram-size = ram / 2
EOF
sudo systemctl daemon-reload

**On plain Arch**, or any distro that ships no such drop-in, build the swapfile yourself. On Btrfs:


sudo btrfs subvolume create /swap
sudo chattr +C /swap
sudo btrfs filesystem mkswapfile -s "$(awk '/MemTotal/ {print $2}' /proc/meminfo)k" /swap/swapfile
printf '\n/swap/swapfile none swap defaults,pri=0 0 0\n' | sudo tee -a /etc/fstab
sudo swapon -p 0 /swap/swapfile

and give zram the higher priority:


# /etc/systemd/zram-generator.conf
[zram0]
zram-size = ram / 2
swap-priority = 100

Then set resume= and resume_offset= for the swapfile and add the resume hook, as described in the other records. The two values come from:


findmnt -no SOURCE -T /swap/swapfile
sudo btrfs inspect-internal map-swapfile -r /swap/swapfile

Do **not** create an on-demand or one-shot swap unit that enables swap only at hibernate time. The Arch wiki states plainly that this is not officially supported, citing systemd issues 16708 and 30083.

Verify

swapon --show lists both zram (PRIO 100) and the swapfile (PRIO 0). omarchy-hibernation-available; echo $? returns 0 on Omarchy. systemctl hibernate completes.

Sources

hibernate-blocked-by-zram-only-swap