You are not logged in.

#1 2014-06-13 15:57:38

Zauber Paracelsus
Member
Registered: 2014-05-23
Posts: 10
Website

ZRam and OpenRC?

I'm interested in running the zram module so that I get a compressed swap space in memory.  Does anyone know what I need to do to get it working with OpenRC?  I believe the zram-config package is set up to utilize SystemD.

Offline

#2 2014-06-13 16:17:23

oliver
Administrator
Registered: 2010-11-04
Posts: 2,209

Re: ZRam and OpenRC?

Take a look here

https://github.com/phunehehe/gentoo-zra … nit.d/zram

(i googled for gentoo openrc and zram)

The dependencies will be different but it's a start

Offline

#3 2014-06-13 16:40:25

Zauber Paracelsus
Member
Registered: 2014-05-23
Posts: 10
Website

Re: ZRam and OpenRC?

Thanks, but I'm probably going to need a finish rather than a start, as I lack sufficient knowledge and experience to adapt that.

Offline

#4 2014-06-14 14:09:24

scjet
Member
From: Canada
Registered: 2010-12-01
Posts: 1,467

Re: ZRam and OpenRC?

here ya go.
His name is Artoo, and you can find him here: https://wiki.manjaro.org/index.php?titl … to_systemd
If anyone knows, he might?
Following along those lines, or on their forum, with manjaro's abilities, might bring you more quickly to your answer than here, for now.

Last edited by scjet (2014-06-14 14:12:36)

Offline

#5 2015-10-03 05:54:31

jrs91
Member
Registered: 2015-10-03
Posts: 1

Re: ZRam and OpenRC?

Zauber Paracelsus wrote:

Thanks, but I'm probably going to need a finish rather than a start, as I lack sufficient knowledge and experience to adapt that.

Did you ever get it worked out?

zram is pretty simple. Just a few commands to turn it on/off (once it's installed.)
https://www.kernel.org/doc/Documentatio … v/zram.txt

Here's the zram script(s) I've used (with systemd:)
https://github.com/mystilleef/FedoraZram

It looks like zram is the same with/without systemd. You will just have to replace systemd's "systemctl start/stop".
OpenRC should have something on startup. (I'll get back when I know.)

save this as: /usr/sbin/zram
call with: zram on
or: zram off

if [ "on" == $1 ]
then

    # Load the kernel module
    NRDEVICES=$(grep -c ^processor /proc/cpuinfo | sed 's/^0$/1/')
    if modinfo zram | grep -q ' zram_num_devices:' 2>/dev/null; then
        MODPROBE_ARGS="zram_num_devices=${NRDEVICES}"
    elif modinfo zram | grep -q ' num_devices:' 2>/dev/null; then
        MODPROBE_ARGS="num_devices=${NRDEVICES}"
    else
        exit 1
    fi
    modprobe zram $MODPROBE_ARGS

    # Determine the size of zRam (equal to the amount of RAM)
    # Note that this is uncompressed
    totalmem=`free | grep -e "^Mem:" | sed -e 's/^Mem: *//' -e 's/  *.*//'`
    mem=$(((totalmem / ${NRDEVICES}) * 1024))

    # initialize the devices
    for i in $(seq ${NRDEVICES}); do
        DEVNUMBER=$((i - 1))
        echo $mem > /sys/block/zram${DEVNUMBER}/disksize
        mkswap /dev/zram${DEVNUMBER}
        swapon -p 5 /dev/zram${DEVNUMBER}
    done

else

    if DEVICES=$(grep zram /proc/swaps | awk '{print $1}'); then
        for i in $DEVICES; do
            swapoff $i
        done
    fi
    rmmod -w zram

fi

It inits the zram module with a zram device for each cpu core:
modprobe zram num_devices=4

and splits full RAM up between each one: (you might want to tweak that, say 70%)
echo 875214848 > /sys/block/zram0/disksize
""

and enables them as swap:
mkswap /dev/zram0
swapon -p 5 /dev/zram0
""

Last edited by jrs91 (2015-10-03 05:56:02)

Offline

Board footer

Powered by FluxBB