#Zram: manual config

1 messages · Page 1 of 1 (latest)

still vessel
#

Hello people! I am trying to configure zram on my Kiss install, and as it has no support I am having to manually adjust it.

This is the script for boot:

#!/bin/sh -e

# Create four zram devices for swap, one for tmpfs
modprobe zram num_devices=2

# create zram devices of $SIZE 2G
# Use lz4 compression on the devices
# Mark the devices as swap devices
# Enable the swap devices
echo lz4 > /sys/block/zram0/comp_algorithm
echo 2G > /sys/block/zram0/disksize
mkswap /dev/zram0
swapon /dev/zram0 -p 10

# Create a 4G ext4 zram device to use as tmpfs with lz4 compression
echo lz4 > /sys/block/zram1/comp_algorithm
echo 4G > /sys/block/zram1/disksize
mkfs.ext4 /dev/zram1
mount /dev/zram1 /tmp

# /tmp requires sticky bit permissions for nonroot user access
chmod 1777 /tmp                     

Script for shutdown:

#!/bin/sh -e

# Disable the swap devices
# Reset the swap devices
swapoff /dev/zram0
echo 1 > /sys/block/zram0/reset

# Unmount /tmp, reset zram device
umount /dev/zram1
echo 1 > /sys/block/zram1/reset

The problem here is that on boot it says "sh: write error: Invalid argument".
But when I run grep zram /proc/swap I can see zram0 is working, and with grep zram /proc/mounts I see that zram1 is running too.
So I'm more worried about that error, maybe it's not working as it should.

Btw: I removed tmpfs from my fstab as it is being mounted here, is it right? My fstab was tmpfs /tmp tmpfs defaults,nosiud,nodev 0 0. Is any of these two approaches right?

still vessel
#

The issue is in the echo lz4 ...

#

It's not allowing me to write it.
If I cat /sys/block/zram0/comp_algorithm it shows [lzo-rle] lzo

brazen dove
#

then you need to either

  • add lz4 support to your kernel
  • just use lzo
#

considering how these last few forums of yours haven't been about gentoo

#

is there a reason you're not using kiss linux support channels?

still vessel
still vessel
still vessel
brazen dove