cd /news/open-source/nixos-set-up-zram-swap · home topics open-source article
[ARTICLE · art-11314] src=gist.github.com ↗ pub= topic=open-source verified=true sentiment=↑ positive

[NixOS] Set Up Zram Swap

The article explains that NixOS can use zramSwap, which creates a compressed swap space in RAM via the kernel's zram module, offering a faster alternative to disk-based swap and reducing SSD wear. It provides configuration steps, including enabling the module, setting priority, algorithm, and memory percentage, while noting trade-offs like CPU usage for compression and incompatibility with hibernation.

read1 min views24 publishedMar 22, 2026

zramSwap in NixOS enables compressed swap space in RAM using the kernel's zram module, acting as a faster, disk-free alternative to traditional swap partitions or files. It's ideal for systems with sufficient RAM and helps reduce SSD wear. #

Enable zramSwap in your configuration with: boot.kernelModules = [ "zram" ]; zramSwap = { enable = true; priority = 100; # Higher than disk swap to prefer zram algorithm = "zstd"; # Balances speed and compression memoryPercent = 50; # Use up to 50% of RAM for zram }; #

Key benefits: Faster than disk swap, no disk I/O, reduces SSD wear. #

Trade-offs: Uses CPU for compression; not suitable for hibernation (requires a swap partition equal to RAM size). #

Advanced use: Supports writeback to a disk device for incompressible data via writebackDevice . For detailed options, see the NixOS Wiki or the zram.nix module source.

── more in #open-source 4 stories · sorted by recency
── more on @nixos 3 stories trending now
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain — perfect for shipping the agent you just read about.

$git push zahid main
Live at https://your-agent.zahid.host
Get free account → Pricing
from €0/mo · no card required
LIVE [news/nixos-set-up-zram-sw…] indexed:0 read:1min 2026-03-22 ·