From 128f742692dc6c7d6e16be593692a90dd2ab8e05 Mon Sep 17 00:00:00 2001 From: den-kloot <1522975+den-kloot@users.noreply.github.com> Date: Mon, 9 Nov 2026 23:32:41 +0100 Subject: [PATCH] omamobile-omarchy 0.1.40: swap on zram at half the RAM (#528) Omarchy 4.5 moves its zram tuning to /usr/lib/systemd/zram-generator.conf.d/90-omarchy.conf, with zram-size = ram, and installs zram-generator on aarch64. With the zram driver in our kernel config (#515), the move past 4.0.6 would give every phone RAM-sized zram: the setting that hung the Pixel 9a under a 6 GB load in #515's test, where half the RAM took 5 GB more with no OOM kill. The package now ships zram-generator.conf.d/91-omamobile.conf, which sets only zram0's size to ram / 2. Drop-ins are read in name order across /usr/lib, /run and /etc, so it overrides Omarchy's size and keeps its zstd and swap priority; a leftover /etc/systemd/zram-generator.conf decides nothing, and a local 99-local.conf (the name Omarchy's migration suggests) still wins. Under Omarchy 4.0.6 an image has no zram-generator, so nothing changes there; where it was installed by hand, the drop-in alone makes a half-RAM device. test/zram.sh checks the staged file and, where zram-generator is installed, runs it on a made-up root (ZRAM_GENERATOR_ROOT, 8 000 000 kB): 7812 MB with Omarchy's drop-in alone, 3906 MB with ours, 3906 MB with a leftover /etc file, 2048 MB with a local 99-local.conf. With the drop-in set to ram the test fails. test/all on the Pixel 9a (zram-generator 1.2.1): 167 ok, none failing. Co-Authored-By: Claude Opus 5.5 --- packages/omamobile-omarchy/install | 4 +- packages/omamobile-omarchy/test/all | 3 +- packages/omamobile-omarchy/test/zram.sh | 46 +++++++++++++++++++ packages/omamobile-omarchy/version | 2 +- .../omamobile-omarchy/zram/91-omamobile.conf | 11 +++++ 5 files changed, 63 insertions(+), 3 deletions(-) create mode 100755 packages/omamobile-omarchy/test/zram.sh create mode 100644 packages/omamobile-omarchy/zram/91-omamobile.conf diff --git a/packages/omamobile-omarchy/install b/packages/omamobile-omarchy/install index 86d11d0d2..3ad8c0b00 100755 --- a/packages/omamobile-omarchy/install +++ b/packages/omamobile-omarchy/install @@ -3,7 +3,8 @@ # Stage omamobile-omarchy into DESTDIR. The pacman hook applies the patch # series after the package transaction; the module-tree cleanup's timer is # enabled by the wants link staged here, and Arch's linux-modules-cleanup is -# held off by a drop-in (lib/modules-cleanup says why). +# held off by a drop-in (lib/modules-cleanup says why). zram/91-omamobile.conf +# caps Omarchy's swap on zram at half the RAM. # ./install DESTDIR set -euo pipefail cd -- "$(dirname -- "${BASH_SOURCE[0]}")" @@ -26,6 +27,7 @@ ln -sfn ../omamobile-modules-cleanup.timer "$u/timers.target.wants/omamobile-mod for f in patches/*.patch; do install -Dm644 "$f" "$d/usr/share/omamobile/omarchy/patches/${f##*/}" done +install -Dm644 zram/91-omamobile.conf "$d/usr/lib/systemd/zram-generator.conf.d/91-omamobile.conf" install -Dm644 libalpm/95-omamobile-omarchy-patches.hook "$d/usr/share/libalpm/hooks/95-omamobile-omarchy-patches.hook" install -Dm644 LICENSE "$d/usr/share/licenses/omamobile-omarchy/LICENSE" install -Dm644 LICENSE.omarchy "$d/usr/share/licenses/omamobile-omarchy/omarchy-MIT" diff --git a/packages/omamobile-omarchy/test/all b/packages/omamobile-omarchy/test/all index 683b518b9..74173a3e6 100755 --- a/packages/omamobile-omarchy/test/all +++ b/packages/omamobile-omarchy/test/all @@ -10,7 +10,7 @@ fail() { printf 'not ok - %s\n' "$1" >&2; exit 1; } pass() { printf 'ok - %s\n' "$1"; } for f in install omamobile-omarchy.install lib/update-bin/* lib/lock-pam lib/modules-cleanup test/update.sh \ - test/lock-pam.sh test/lock-glance test/sleep-lock.sh test/modules-cleanup.sh; do + test/lock-pam.sh test/lock-glance test/sleep-lock.sh test/modules-cleanup.sh test/zram.sh; do bash -n "$f" || fail "$f parses" done for f in bin/omamobile-omarchy-patches bin/omamobile-update test/patches.py; do @@ -63,6 +63,7 @@ if command -v systemd-analyze >/dev/null; then fi pass "install stages the module cleanup, its timer's wants link and the drop-in for Arch's" bash test/modules-cleanup.sh || fail "modules-cleanup" +bash test/zram.sh || fail "zram drop-in" # Every patch file says what it is for, before its first diff for p in patches/*.patch; do diff --git a/packages/omamobile-omarchy/test/zram.sh b/packages/omamobile-omarchy/test/zram.sh new file mode 100755 index 000000000..7566267d3 --- /dev/null +++ b/packages/omamobile-omarchy/test/zram.sh @@ -0,0 +1,46 @@ +#!/bin/bash +# SPDX-License-Identifier: MIT +# zram/91-omamobile.conf against Omarchy 4.5's drop-in: the staged file, and, +# when zram-generator is installed (or ZRAM_GENERATOR names it), the size it +# gives /dev/zram0 in a made-up root (ZRAM_GENERATOR_ROOT) with an 8 000 000 kB +# MemTotal. Nothing on this machine's zram is read or changed. +set -euo pipefail +cd -- "$(dirname -- "${BASH_SOURCE[0]}")/.." +fail() { printf 'not ok - %s\n' "$1" >&2; exit 1; } +pass() { printf 'ok - %s\n' "$1"; } +t=$(mktemp -d); trap 'rm -rf "$t"' EXIT + +./install "$t/stage" >/dev/null +f=$t/stage/usr/lib/systemd/zram-generator.conf.d/91-omamobile.conf +[[ -f $f ]] || fail "zram drop-in staged" +[[ $(grep -vE '^[[:space:]]*(#|$)' "$f") == $'[zram0]\nzram-size = ram / 2' ]] \ + || fail "zram drop-in sets only zram0's size, to half the RAM" +[[ 91-omamobile.conf > 90-omarchy.conf && 91-omamobile.conf < 99-local.conf ]] \ + || fail "zram drop-in sorts after Omarchy's and before a local one" +pass "the zram drop-in is staged and sets half the RAM" + +gen=${ZRAM_GENERATOR:-/usr/lib/systemd/system-generators/zram-generator} +if [[ ! -x $gen ]]; then + pass "# SKIP zram-generator not installed: sizes not checked" + exit 0 +fi +r=$t/root; d=$r/usr/lib/systemd/zram-generator.conf.d +mkdir -p "$d" "$r/proc" "$r/etc/systemd/zram-generator.conf.d" +printf 'MemTotal: 8000000 kB\nMemFree: 4000000 kB\n' > "$r/proc/meminfo" +: > "$r/proc/cmdline" +# Omarchy 4.5's default/systemd/zram-generator.conf.d/90-omarchy.conf. +printf '[zram0]\nzram-size = ram\ncompression-algorithm = zstd\nswap-priority = 100\n' > "$d/90-omarchy.conf" +size() { + rm -rf "$t/out"; mkdir "$t/out" + ZRAM_GENERATOR_ROOT=$r "$gen" "$t/out" 2>&1 | sed -n 's/.*\/dev\/zram0 with \([0-9]*\)MB.*/\1/p' +} +[[ $(size) == 7812 ]] || fail "zram-generator reads the made-up root (Omarchy alone: the whole RAM)" +cp "$f" "$d/" +[[ $(size) == 3906 ]] || fail "with the drop-in, zram0 is half the RAM" +grep -qx 'Priority=100' "$t/out/dev-zram0.swap" || fail "Omarchy's swap priority still applies" +# An /etc main file left from archinstall or an older Omarchy is outranked. +printf '[zram0]\nzram-size = ram\n' > "$r/etc/systemd/zram-generator.conf" +[[ $(size) == 3906 ]] || fail "a leftover /etc/systemd/zram-generator.conf doesn't undo it" +printf '[zram0]\nzram-size = 2048\n' > "$r/etc/systemd/zram-generator.conf.d/99-local.conf" +[[ $(size) == 2048 ]] || fail "a local 99-local.conf still decides" +pass "zram-generator: half the RAM over Omarchy's, a local drop-in still wins" diff --git a/packages/omamobile-omarchy/version b/packages/omamobile-omarchy/version index 528bd040e..7172442a1 100644 --- a/packages/omamobile-omarchy/version +++ b/packages/omamobile-omarchy/version @@ -1 +1 @@ -0.1.39 +0.1.40 diff --git a/packages/omamobile-omarchy/zram/91-omamobile.conf b/packages/omamobile-omarchy/zram/91-omamobile.conf new file mode 100644 index 000000000..89598e9ab --- /dev/null +++ b/packages/omamobile-omarchy/zram/91-omamobile.conf @@ -0,0 +1,11 @@ +# Omarchy Mobile: swap on zram at half the RAM, not Omarchy's whole RAM. +# Omarchy's 90-omarchy.conf sets zram-size = ram. On the Pixel 9a (7.4 GB) +# that hung the phone under a 6 GB load until a restart, while ram / 2, +# stock Android's size there, took 5 GB more with no OOM kill and SSH still +# answering (device/tegu/NOTES.md, 2026-11-08). Drop-ins are read in name +# order across /usr/lib, /run and /etc, so this one, sorting after +# 90-omarchy.conf, sets the size and leaves Omarchy's other settings +# (zstd, the swap priority) alone. A local size goes in +# /etc/systemd/zram-generator.conf.d/99-local.conf, which sorts after this. +[zram0] +zram-size = ram / 2