Skip to content

Instantly share code, notes, and snippets.

@davidar
Created February 22, 2026 04:32
Show Gist options
  • Select an option

  • Save davidar/243ca325716c4cca0baf14a7b3069857 to your computer and use it in GitHub Desktop.

Select an option

Save davidar/243ca325716c4cca0baf14a7b3069857 to your computer and use it in GitHub Desktop.
earlyoom configuration for desktop Linux — swap-aware OOM prevention with process targeting

earlyoom for Desktop Linux

The default kernel OOM killer reacts too late for desktop use — by the time it fires, the system is deep in swap thrash and unresponsive. systemd-oomd is better but still too conservative for desktops with lots of browser tabs.

earlyoom monitors memory and swap usage and kills processes before the system becomes unusable.

Install

# Fedora / rpm-ostree
sudo dnf install earlyoom
# or: rpm-ostree install earlyoom

# Debian/Ubuntu
sudo apt install earlyoom

# IMPORTANT: rpm-ostree doesn't auto-enable services after install
sudo systemctl enable --now earlyoom

Configuration

Edit /etc/default/earlyoom:

EARLYOOM_ARGS="-m 4 -s 50 --prefer '(Web Content|Isolated Web)' --avoid '(gnome-shell|gnome-session|Xwayland|pipewire)'"

What this does

Flag Effect
-m 4 Trigger when available RAM drops below 4% (~1.2 GB on 32 GB)
-s 50 Also trigger when swap usage exceeds 50% — catches swap thrash before it freezes the system
--prefer Kill browser content processes first (they're recoverable — just reload the tab)
--avoid Protect desktop session processes (killing these logs you out)

The key addition over the Fedora default is -s 50 — without it, earlyoom only watches RAM, and the system can become unresponsive from swap thrashing while still having "enough" RAM by earlyoom's measure.

Verify

systemctl status earlyoom
journalctl -u earlyoom       # see kill history
journalctl -u earlyoom -f    # watch live

Why not systemd-oomd?

systemd-oomd uses PSI (Pressure Stall Information) metrics and cgroup-level memory limits, which is architecturally cleaner but reacts slower in practice. On a desktop with browsers eating 20+ GB of swap, earlyoom's simple percentage-based approach triggers sooner and prevents the 30-60 second freezes that make you reach for the power button.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment