#!/bin/bash | |
# Raspberry Pi ZRAM script | |
# Tuned for quad core, 1 GB RAM models | |
# put me in /etc/init.d/zram.sh and make me executable | |
# then run "sudo update-rc.d zram.sh defaults" | |
modprobe zram | |
echo 3 >/sys/devices/virtual/block/zram0/max_comp_streams | |
echo lz4 >/sys/devices/virtual/block/zram0/comp_algorithm | |
echo 268435456 >/sys/devices/virtual/block/zram0/mem_limit | |
echo 536870912 >/sys/devices/virtual/block/zram0/disksize | |
mkswap /dev/zram0 | |
swapon -p 0 /dev/zram0 | |
sysctl vm.swappiness=70 |
This comment has been minimized.
This comment has been minimized.
I second that, works great on mint I am now testing on osmc. |
This comment has been minimized.
This comment has been minimized.
I secound that. Thanks for this little script. |
This comment has been minimized.
This comment has been minimized.
This was useful - thanks! Is there a way to turn it off once I don't need it anymore? I don't really understand what it's doing. |
This comment has been minimized.
This comment has been minimized.
it is increasing your swap. |
This comment has been minimized.
This comment has been minimized.
@mfranzs You can disable it by swapoff /dev/zram0
modprobe -r zram |
This comment has been minimized.
This comment has been minimized.
For a more detailed reference: https://github.com/openSUSE/kernel/blob/master/Documentation/blockdev/zram.txt |
This comment has been minimized.
This comment has been minimized.
You might want to update your script to benefit from the new zram backing device -- where uncompressible pages get stored without agressive flushing. I'm getting wonderful results -- better yet when combining parallel backing devices. Here is what I use on my setup of an sd card plus 4 cheap usb pendrives with a dedicated partition to serve as the backing device on each: modprobe zram num_devices=5; ((z=0)); for d in /dev/mmcblk0pX /dev/sdaX /dev/sdbX /dev/sdcX /dev/sddX; do echo $d >/sys/block/zram${z}/backing_dev; echo lz4 >/sys/devices/virtual/block/zram${z}/comp_algorithm; echo 96m >/sys/devices/virtual/block/zram${z}/mem_limit; echo 512m >/sys/devices/virtual/block/zram${z}/disksize; mkswap /dev/zram${z}; swapon -p 15 /dev/zram${z}; ((z++)); done Notes:
|
This comment has been minimized.
This comment has been minimized.
When "sudo update-rc.d zram.sh defaults" I get:
So... what now? |
This comment has been minimized.
Thank you so much for doing the work to figure this out and create the script. This has been a life saver for the project I'm working on.