RPI

#!/bin/bash  
cores=$(nproc --all)  
modprobe zram num_devices=$cores  

swapoff -a  

totalmem=`free | grep -e "^Mem:" | awk '{print $2}'`  

disk_size=$(( ($totalmem / $cores)* 250 * 3 ))  

mem=$(( ($totalmem / $cores)* 250 ))  
#disc=$(($mem/3))  

echo "Start"  
echo $mem  
echo $disk_size  

core=0  
while [ $core -lt $cores ]; do  
 echo lz4> /sys/block/zram$core/comp_algorithm  
 echo $mem > /sys/block/zram$core/mem_limit  
 echo $disk_size > /sys/block/zram$core/disksize  
 mkswap /dev/zram$core  
 swapon -p 5 /dev/zram$core  
 sysctl vm.swappiness=10  
 #was 5  
 let core=core+1  
done
[Unit]  
Description=Create ZramSwap  

[Service]  
Type=oneshot  
ExecStart=/root/zram.sh  

[Install]  
WantedBy=multi-user.target

https://docs.k0sproject.io/v1.23.6+k0s.2/raspberry-pi4/