{"slug": "nixos-set-up-zram-swap", "title": "[NixOS] Set Up Zram Swap", "summary": "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.", "body_md": "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.\n-\nEnable zramSwap in your configuration with:\nboot.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 };\n-\nKey benefits: Faster than disk swap, no disk I/O, reduces SSD wear.\n-\nTrade-offs: Uses CPU for compression; not suitable for hibernation (requires a swap partition equal to RAM size).\n-\nAdvanced use: Supports writeback to a disk device for incompressible data via\nwritebackDevice\n.\nFor detailed options, see the NixOS Wiki or the zram.nix module source.", "url": "https://wpnews.pro/news/nixos-set-up-zram-swap", "canonical_source": "https://gist.github.com/kekneus373/8e22121c23d0ced11b1c8c4a4fd1a2e6", "published_at": "2026-03-22 19:39:18+00:00", "updated_at": "2026-05-23 12:06:13.329140+00:00", "lang": "en", "topics": ["open-source", "developer-tools", "hardware"], "entities": ["NixOS", "zram", "zstd"], "alternates": {"html": "https://wpnews.pro/news/nixos-set-up-zram-swap", "markdown": "https://wpnews.pro/news/nixos-set-up-zram-swap.md", "text": "https://wpnews.pro/news/nixos-set-up-zram-swap.txt", "jsonld": "https://wpnews.pro/news/nixos-set-up-zram-swap.jsonld"}}