1

I use very little of my Raspberry Pi 2B's CPU, but I frequently need more memory. In order to free up memory on my Pi running Ubuntu MATE, I set up Zram by installing zram-config. I was pleasantly surprised at the difference it made.

Now, after installing Raspbian Stretch for the first time I decided to set up Zram on it. I followed this guide to configure Zram, and everything went as it should, on boot-up four Zram blocks are set up. There is also now 1 GB of swap space instead of 100 MiB. There does not seem to be any difference in behaviour however.

On Ubuntu MATE htop shows a lot of swapping (into the Zram, there is no swapfile) but on Raspbian there is no swapping happening at all. There used to be a little bit of swap to the swapfile, but now there is nothing at all. (see image below).

enter image description here

EDIT: My Zram is actually active, but the swap is still very low. There is generally just a little bit more swap than there was originally without Zram. My swappiness is set to 60, the same as on my Ubuntu. Maybe it just works a little differently on Raspbian.

1

There are a few issues since the current version of bash is not interpreting zram.sh properly. You can test wether bash interpretes your zram.sh well by executing (as root) following script -no impact! just see! The instructions modprobe and swapoff are disabled-:

#!/bin/bash   
cores=$(nproc --all)  
echo $cores  
# modprobe zram num_devices=$cores  
#swapoff -a  
tot=`free | grep -e "^Mem:" | awk '{print $2}'`  
memex=$(( ($tot / $cores)* 1024 ))
echo "total: $tot"
echo "memex:" $memex
core=0  
while [ $core -lt $cores ]; do  

    echo "core: $core"  
    echo $memex  
    core=$((core+1))  
done
memey=$(echo "scale=0;1024*($tot/$cores)" | bc)    
echo "total: $tot"
echo "memey:" $memey
while [ $core -lt $cores ]; do  

    echo "core: $core"  
    echo $memey  
    core=$((core+1))  
done

Please find my solution by clicking here
Zram size goes up and down and works flawlessly for me This works also on my Pi B+. On Pi B+ the zram size should not exceed the size of the free memory; On the Pi 2 I use 2048 as factor.

zram is active

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy