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

Set up zram so the desktop stops freezing under memory pressure

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

The generic Arch advice is sound (zram-generator, [zram0] with zram-size/compression-algorithm, systemd-zram-setup@zram0.service, the swappiness/watermark/page-cluster tuning, and the correct default of min(ram / 2, 4096)), and the danger note about hibernation needing real disk swap is right. It is wrong for Omarchy 4, which is in applies_to: Quattro already ships /usr/lib/systemd/zram-generator.conf.d/90-omarchy.conf (zram-size = ram, zstd, swap-priority = 100) and already enables systemd-oomd.service in install/config/enable-services.sh, so the stated symptom (Swap: 0B) should not occur there, and worse, the prescribed lever is the wrong one: zram-generator reads the main config file *first* and lets drop-ins override it, so a hand-written /etc/systemd/zram-generator.conf is silently overridden by Omarchy's shipped drop-in and the user's min(ram / 2, 16384) never takes effect.

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

zram is volatile RAM. You cannot hibernate to it. If you rely on hibernate (Omarchy's omarchy-hibernation-setup), you still need a real disk swap file or partition with the correct resume= kernel parameter. Adding zram does not replace it. vm.swappiness=180 is only sensible when zram is the *only* swap. With a disk swap partition also active it will cause heavy disk swapping.

Symptom

Compiling something large or opening too many browser tabs makes the whole desktop lock up for minutes (Hyprland stops repainting, the mouse stutters) and eventually a process is OOM-killed. free -h shows Swap: 0B.

Cause

No swap at all means the kernel has nowhere to push cold pages, so it thrashes the page cache and stalls before the OOM killer finally fires. zram gives compressed in-RAM swap, which absorbs this far better than no swap on a machine with an SSD you would rather not write to.

Fix

Check what you already have before writing anything: zramctl, swapon --show, cat /usr/lib/systemd/zram-generator.conf.d/*.conf /etc/systemd/zram-generator.conf* 2>/dev/null.

**Plain Arch, no zram yet:** the record's steps are correct.


sudo pacman -S zram-generator
# /etc/systemd/zram-generator.conf
# [zram0]
# zram-size = min(ram / 2, 16384)
# compression-algorithm = zstd
sudo systemctl daemon-reload
sudo systemctl start systemd-zram-setup@zram0.service

**Omarchy 4:** zram is already configured (zram-size = ram, zstd, swap-priority = 100) and systemd-oomd is already enabled. Do not create /etc/systemd/zram-generator.conf, it loses to the shipped drop-in. To change the size, add a drop-in that sorts after Omarchy's:


sudo mkdir -p /etc/systemd/zram-generator.conf.d
printf '[zram0]\nzram-size = min(ram / 2, 16384)\n' | sudo tee /etc/systemd/zram-generator.conf.d/99-local.conf
sudo systemctl daemon-reload
sudo systemctl restart systemd-zram-setup@zram0.service

The sysctl tuning and the hibernation warning (omarchy-hibernation-setup gives the disk swapfile priority 0, zram sits above it at 100, and vm.swappiness=180 only suits a zram-only setup) stay as written.

Verify

zramctl shows /dev/zram0 with your chosen size and zstd algorithm, swapon --show lists it, and free -h shows a non-zero Swap total. Under load the desktop stays responsive.

Sources

zram-swap-oom-freezes