Size zram the way Fedora does

zram-size = min(ram, 8192) is Fedora's default since F34, where
zram-fraction=1.0 with max-zram-size=8192 has run on desktops for five
years. The previous min(ram / 2, 8192) halved that on every machine
below 16G with nothing behind the fraction; at 16G and above the two
already agree.

A changed size only reaches a running device on the next boot, so the
migration resizes an empty device now and asks for a reboot otherwise.
It asks the generator what the config evaluates to rather than
repeating the expression here, and does neither when the device already
matches.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
David Heinemeier Hansson
2026-07-26 12:58:02 -07:00
co-authored by Claude Opus 5
parent f01acc1de9
commit 187c2ecf7f
3 changed files with 159 additions and 5 deletions
@@ -1,10 +1,17 @@
# Compressed swap in RAM. zstd averages around 3:1, so the worst case for a
# full device is roughly a third of the size below.
# Compressed swap in RAM, sized the way Fedora has shipped it since F34: all of
# memory, capped at 8G. Fedora weighed the worry that incompressible pages would
# tie up RAM against five years of desktops reporting no trouble from it, which
# is more field evidence than we could gather on our own.
#
# The generator's own default caps this at 4G, which sends machines with a lot
# of memory to the disk swapfile far earlier than they need to go.
# The cap is what bounds the downside. A browser-heavy desktop can drive zstd
# down near 1.1:1, where the device backs far less than it advertises, and 8G
# keeps that bounded on any machine large enough to notice. The disk swapfile
# sits behind it at pri=0 for everything past that.
#
# Fedora spells this zram-fraction = 1.0 with max-zram-size = 8192; both keys
# are deprecated in favour of zram-size, which computes the same numbers.
[zram0]
zram-size = min(ram / 2, 8192)
zram-size = min(ram, 8192)
compression-algorithm = zstd
# Above the pri=0 that omarchy-hibernation-setup gives the disk swapfile, so