#!/bin/sh

# ensure zram module is loaded
/sbin/modprobe zram
{% for i in range(zram_num_devices) %}

## SETUP FOR ZRAM{{ i }}
# set compression algorithm
echo zstd > /sys/block/zram{{ i }}/comp_algorithm
# set disksize
echo {{ ansible_memtotal_mb }}M > /sys/block/zram{{ i }}/disksize
# set memory limit
echo {{ ansible_memtotal_mb }}M > /sys/block/zram{{ i }}/mem_limit
# activate swaps
/sbin/mkswap -L zram{{ i }} /dev/zram{{ i }}
# swapon
/sbin/swapon -p 10 /dev/zram{{ i }}
{% endfor %}
