# zram swap on hp-chell (KDE neon) Set up **2026-03-05**, reconstructed on 2026-09-27 from `~/.bash_history` and the live config. It replaces the disk swapfile with compressed swap in RAM. That suits this machine: 15GiB RAM, and neon's root lives on a slow microSD card in the built-in slot (`sda`) that you don't want to swap to or wear out. ## Current state (2026-09-27) ``` $ zramctl NAME ALGORITHM DISKSIZE DATA COMPR TOTAL STREAMS MOUNTPOINT /dev/zram0 zstd 8G 4K 59B 20K [SWAP] $ swapon --show NAME TYPE SIZE USED PRIO /dev/zram0 partition 8G 0B 100 ``` The zram device is the only swap. zswap is off (`/sys/module/zswap/parameters/enabled` = `N`), and there's nothing zram-related on the kernel command line. ## What was done 1. **Installed `zram-tools`** (Debian's simple `zramswap` service; not `systemd-zram-generator`, which isn't installed): `sudo apt install zram-tools`, `sudo systemctl enable --now zramswap`. 2. **Configured `/etc/default/zramswap`**. The file is still the package's own conffile (`dpkg -V zram-tools` flags it as modified), with these lines added at the end: ``` ENABLED=true ALGO=zstd SIZE=8192 PRIORITY=100 ``` - `ALGO=zstd`: better compression than the default `lz4`, at some CPU cost. Fine on this 4-core Core m7 for swap-sized traffic. - `SIZE=8192`: an 8GiB zram device, a fixed size in MiB. `PERCENT` isn't set; if set, it would override `SIZE`. That's the uncompressed capacity; actual RAM used is the compressed size (`COMPR`/`TOTAL` in `zramctl`). - `PRIORITY=100`: above any disk swap, so zram is used first. Tuned over several stop/edit/start rounds (the history shows `systemctl stop zramswap` / `nano` / `start` three or four times). Only the final values are known. Apply changes with `sudo systemctl restart zramswap`. 3. **Disabled the disk swapfile**: in `/etc/fstab`, ``` # removed swapfile, using zram instead #/swapfile swap swap defaults 0 0 ``` then `sudo swapoff /swapfile`. 4. **Raised `vm.swappiness` to 100**, at runtime only (`sudo sysctl vm.swappiness=100`). See the loose ends below. ## Loose ends (fixed 2026-09-27) - **`vm.swappiness=100` hadn't been made persistent**: it had been set with `sysctl` at runtime only and was back to the default 60. Now persisted in `/etc/sysctl.d/99-zram.conf` (`vm.swappiness=100`) and applied live. Swapping to zram is cheap, so a high swappiness is the usual choice. Not changed: `vm.page-cluster` (still `3`). Some zram guides set it to `0`, since zram has no seek cost and readahead just wastes work. - **The unused `/swapfile`** (512MiB, dated 2026-03-04, fstab line commented out) was deleted. On 2026-09-28 a new **16GB `/swapfile`** was added at priority 10 (below zram's 100) for hibernation. See "Suspend-then-hibernate" in `NEON-CUSTOMIZATIONS.md`. zram is still the everyday swap. ## Reapplying on a fresh neon install ``` sudo apt install zram-tools sudo tee -a /etc/default/zramswap >/dev/null <<'EOF' ENABLED=true ALGO=zstd SIZE=8192 PRIORITY=100 EOF sudo systemctl enable --now zramswap # comment out any /swapfile line in /etc/fstab, then: sudo swapoff /swapfile # persist swappiness echo 'vm.swappiness=100' | sudo tee /etc/sysctl.d/99-zram.conf && sudo sysctl --system ``` Check with `zramctl` and `swapon --show`.