Skip to content

feat(swap): zswap over /var/swap/swapfile instead of zram, as on Dakota - #1292

Closed
hanthor wants to merge 1 commit into
feat/dakota-fish-shellfrom
feat/dakota-zswap
Closed

hanthor wants to merge 1 commit into
feat/dakota-fish-shellfrom
feat/dakota-zswap

Conversation

@hanthor

@hanthor hanthor commented Nov 16, 2026

Copy link
Copy Markdown
Member

Adopts Dakota's swap: zswap in front of a disk-backed /var/swap/swapfile, no zram (owner decision on #1224).

What changed

  • From Dakota (bf271777), verbatim:
    • usr/lib/bootc/kargs.d/20-zswap.toml and usr/lib/sysctl.d/60-zswap.conf come from elements/bluefin/zswap-config.bst.
    • usr/libexec/bluefin-swapfile-init, bluefin-swapfile-init.service, var-swap-swapfile.swap and the static swap.target.wants link come from files/swapfile/ and elements/bluefin/swapfile.bst.
  • Removed: zram-generator and zram-generator-defaults are out of packages/utah.toml. Hummingbird's base doesn't ship either one.
  • Utah-only: zstd in the initramfs.
    • Hummingbird's kernel (7.3.3-200.fc44) has CONFIG_CRYPTO_ZSTD=m, with lzo as the default compressor. zswap reads zswap.compressor=zstd during kernel init, so it can only load the module from the initramfs.
    • usr/lib/dracut/dracut.conf.d/50-utah-zswap-zstd.conf adds add_drivers+=" zstd ".
    • scripts/regenerate-initramfs.sh now fails the build when the kernel builds zstd as a module and the initramfs doesn't carry it. Kernels with zstd built in, or without it, have nothing to carry.
    • Containerfile.kernel and the install-*-kernel scripts are untouched.
  • Utah-only: SELinux label.
    • Dakota has no SELinux. Fedora's policy has no rule for /var/swap, so the swapfile would be var_t and swapon would be denied.
    • usr/share/selinux/packages/utah-swapfile.cil is a one-line module that labels /var/swap/swapfile as swapfile_t.
    • configure-services.sh installs it with semodule -n -i into Hummingbird's /usr/lib/selinux store, so it ships in the image and survives ostree's per-deployment semodule -N --refresh. The script then checks the label with matchpathcon.
    • bluefin-swapfile-init runs restorecon on the file right after touch, before dd and mkswap, when SELinux is enabled.
  • Contract: contracts/bluefin-desktop.toml asserts every new file, plus the kargs, sysctls, dracut line, swap unit and restorecon.
  • Tests: tests/test_zswap_swapfile.py is new. tests/test_regenerate_initramfs.py covers the zstd guard. The configure-services harness stubs semodule and matchpathcon.
  • Docs: the skill reference desktop-contract/references/dakota-system-defaults.md gets a Swap section and a corrected Lid/sleep note. containerfile.md covers the initramfs check.

Flagged

  • Gaming flavors: the OGC kernel is built from x86_64_defconfig. I haven't confirmed whether it has CONFIG_ZSWAP; if it doesn't, the kargs are ignored and the swapfile works as plain swap. Turning zswap on there is a kernel-cache change and isn't in this PR.
  • Stale comment: install-ogc-kernel.sh still enables CONFIG_ZRAM, and its comment gives zram-generator as the reason. That's harmless; I left it alone because the kernel-cache rules put that script out of scope here.

Verification

  • just check passes (1343 tests).
  • In the pinned Hummingbird os-minimal image:
    • semodule -n -i utah-swapfile.cil, then matchpathcon /var/swap/swapfile gives system_u:object_r:swapfile_t:s0.
    • The label is still there after semodule -N --refresh, and /var/swap itself stays var_t.
    • The kernel config is CONFIG_ZSWAP=y, CONFIG_CRYPTO_ZSTD=m and CONFIG_ZSWAP_COMPRESSOR_DEFAULT="lzo", and the module sits at kernel/crypto/zstd.ko.xz.
  • Not booted in a VM. Once the image builds, check swapon --show, /sys/module/zswap/parameters/compressor (should read zstd) and ls -Z /var/swap/swapfile.

Stacked on #1291 (feat/dakota-fish-shell).

Closes #1224

Copy Dakota's elements/bluefin/zswap-config.bst (20-zswap.toml kargs,
60-zswap.conf sysctls) and swapfile.bst (bluefin-swapfile-init, its
oneshot unit, var-swap-swapfile.swap and the static swap.target.wants
link), and drop zram-generator(-defaults).

Two Utah-only pieces Dakota does not need:
- Hummingbird's kernel builds zstd as a module (CONFIG_CRYPTO_ZSTD=m) and
  zswap resolves zswap.compressor=zstd during kernel init, so a dracut
  drop-in adds zstd to the initramfs and regenerate-initramfs.sh fails the
  build if a modular zstd is missing from it.
- Utah keeps SELinux: a one-line CIL module labels /var/swap/swapfile
  swapfile_t (installed into the /usr/lib/selinux store at build time and
  checked with matchpathcon), and the init script restorecons the file
  before writing it.

Closes #1224

Assisted-by: Claude Opus via GitHub Copilot
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions github-actions Bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Nov 16, 2026
@github-actions

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: hanthor

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@hivecommons-hive hivecommons-hive Bot added author/clanker A contributor's own hive authored this PR under their login no-dco A commit is missing Signed-off-by — run `git rebase --signoff` role/trusted Author is trusted for unattended merge (trusted-author role or registry/claim tier in require_tiers) stage/072-returned-to-contributor Contributor PR: CI red, changes requested or conflicting; diagnosis posted, author must act labels Nov 16, 2026
@hivecommons-hive hivecommons-hive Bot linked an issue Nov 16, 2026 that may be closed by this pull request
@hivecommons-hive

hivecommons-hive Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Withdrawn: this PR is not back in your court after all. The failing checks (contract) are red on the base branch too; this change did not break them. There is nothing to fix here: the PR is back on the normal path, and the hive checks it again once the base branch is green.

@hivecommons-hive hivecommons-hive Bot added stage/050-review-pending Review swarm requested; awaiting a verdict for the current head and removed stage/072-returned-to-contributor Contributor PR: CI red, changes requested or conflicting; diagnosis posted, author must act labels Nov 16, 2026
@hanthor

hanthor commented Nov 16, 2026

Copy link
Copy Markdown
Member Author

Folded into the part-2 landing PR (fold/dakota-sq) with this change unchanged apart from rebase and conflict resolution. Closing here; review continues there.

@hanthor hanthor closed this Nov 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. author/clanker A contributor's own hive authored this PR under their login no-dco A commit is missing Signed-off-by — run `git rebase --signoff` role/trusted Author is trusted for unattended merge (trusted-author role or registry/claim tier in require_tiers) stage/050-review-pending Review swarm requested; awaiting a verdict for the current head

Projects

None yet

Development

Successfully merging this pull request may close these issues.

parity(dakota): zswap + swapfile instead of zram

1 participant