Zram swap on Debian and Linux Mint
Instead of creating a separate swap partition or using a swapfile, its possible to create a high-speed swap device in RAM itself with the Linux kernel module zram. Even though its been around for years, I've only learned about it recently and its pretty cool!
Zram swap - not to be confused with zswap - creates a compressed block device in memory, and the RAM assigned to it is only used for swapping as-needed (until then, the RAM is still available for use by applications).
Swap data stored is compressed thereby allowing more data to be stored in RAM. Performing read/write operations in memory is both a speed boost and reduces wear on SSD drives, at the cost of more CPU-intensive activity.
- OS is Linux Mint Debian Edition (LMDE)
- Enabled on my Thinkpad T480s with 8GB RAM
- Assign 25% of memory to the
zram0device for swap
- No other swap devices are in use
Disable any active swaps ...
$ sudo swapoff --all
$ sudo apt install zram-tools
Stop zram ...
$ sudo zramswap stop
Settings are modified in
PERCENT and set amount of RAM used by zram as a percentage of the total memory available ...
PRIORITY and set the priority of the swap device ...
Check if any swap devices exist in
fstab (example: I had swapfile
$ grep swap /etc/fstab /dev/mapper/vgmint-swap_1 none swap sw 0 0
If so, comment out the swap entries to disable.
$ sudo zramswap start $ zramctl
» Next: Getting started with Git and GitLab
« Previous: DoH and custom DNS servers with OpenWrt