eylles / zram-service

a simplle zram initscript
GNU General Public License v3.0
3 stars 2 forks source link

Robin Twiggs #1

Open robintwiggs opened 2 years ago

robintwiggs commented 2 years ago

Hi There,

Thanks for sharing this code, which I have found to be accurate and useful.

I've made a small modification to zram.sh which you may find useful.

After 'PRIORITY=100': MEM_LIMIT_PERCENTAGE=0

Before 'echo "zram device initiated"': if [ ${MEM_LIMIT_PERCENTAGE} -gt 0 ]; then MEM_LIMIT_SIZE=$(( MEMORY_TOTAL * MEM_LIMIT_PERCENTAGE / 100)); echo "${MEM_LIMIT_SIZE}" > /sys/block/zram0/mem_limit fi;

This allowed me to set MEM_LIMIT_PERCENTAGE=20 and RAM_PERCENTAGE=60 in /etc/default/zram-config when I'm expecting a compression ratio of 3, so that I can be confident my MEM_LIMIT_PERCENTAGE will not be exceeded under any conditions.

eylles commented 2 years ago

Thanks, i will push this change as a commit with your name on the author field.

robintwiggs commented 2 years ago

Thanks,

Another minor tweak I discovered is necessary on systems with systemd installed

zram.sh needs to have a shebang at the top of the file - for which I used the following as the code in the script is sh:

!/usr/bin/env sh