Zram swap on Debian and LMDE

Last edited on 2024-10-02 Tagged under  #debian   #lmde   #linux 

Instead of creating a dedicated swap partition or using a swapfile for Linux, I use Zram swap (not to be confused with zswap) to create a compressed block device in memory.

Any RAM assigned to it is only used for swapping as-needed (until then, the RAM is still available for use by applications). 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).

Setup

Steps

1. Disable active swaps

$ sudo swapoff --all

2. Install

$ sudo apt install zram-tools

3. Configure

Stop zramswap:

$ sudo zramswap stop

Settings are modified in /etc/default/zramswap.

Uncomment PERCENT and set amount of RAM used by zram as a percentage of total memory available:

PERCENT=25

Uncomment PRIORITY and set the priority of the swap device:

PRIORITY=100

4. Fstab

Check if any swap devices exist in fstab:

$ grep swap /etc/fstab
/dev/mapper/vgmint-swap_1 none            swap    sw              0       0

If so, comment out the swap entries to disable.

5. Start

$ sudo zramswap start
$ zramctl

Resources

You can like, share, or comment on this post on the Fediverse 💬

Thanks for reading! Read other posts?

» Next: MintyFresh: My configuration script for Linux Mint Debian Edition (LMDE 6)

« Previous: Install Linux Mint Debian Edition (LMDE 6) in Expert Mode