ZRAM on the Jornada

Regarding Zram: I use it already for a few weeks - it works very well on the Jornada. A Kernel module is already in the new 3.16.81 folder. I configured the script to use 50% of the RAM as Zram - at least on a system with 128MB RAM this works very well. You can edit the “FRACTION=” value - it defines the percentage of your RAM that is used for Zram.

- make sure you have the folder with the latest Kernel modules in your /lib/modules folder: http://www.sp-net.at/nextcloud/s/SQbqbX64QdZarop?path=%2Fkernel3.16.81

- copy the attached script to /etc/init.d/zram

- Make the script executable:

$ sudo chmod +x /etc/init.d/zram

-make sure the insserv package is installed (it provides a easy way to add scripts to SysV)

$ sudo apt-get install insserv

-and add zram so that it starts automatically at boot

$ sudo insserv zram

Now reboot your Jornada!


Script:

# Author: Antonio Galea <antonio.galea@gmail.com>
#
# Thanks to Przemysław Tomczyk for suggesting swapoff parallelization
# Distributed under the GPL version 3 or later, see terms at
# https://gnu.org/licenses/gpl-3.0.txt

### BEGIN INIT INFO
# Provides:          zram
# Required-Start:    $local_fs
# Required-Stop:     $local_fs
# Default-Start:     S
# Default-Stop:      0 1 6
# Short-Description: Use compressed RAM as in-memory swap
# Description:       Use compressed RAM as in-memory swap
### END INIT INFO

FRACTION=50
MEMORY=$(perl -ne '/^MemTotal:\s+(\d+)/ && print $1*1024' < /proc/meminfo)
CPUS=$(nproc)
SIZE=$((MEMORY * FRACTION / 100 / CPUS))

case "$1" in
    start)
        param=$(modinfo zram | grep num_devices | cut -f2 -d: | tr -d ' ')
        modprobe zram $param=$CPUS

        for n in $(seq $CPUS)
        do
            i=$((n - 1))
            echo $SIZE > /sys/block/zram$i/disksize
            mkswap /dev/zram$i
            swapon /dev/zram$i --priority 10
        done
        ;;
    stop)
        for n in $(seq $CPUS)
        do
            i=$((n - 1))
            swapoff /dev/zram$i && echo "zram: disabled disk $n of $CPUS" &
        done

        wait
        sleep .5
        modprobe --remove zram
        ;;
    *)
        echo "Usage: $(basename $0) (start | stop)"
        exit 1
        ;;
esac

# End of file