Ubuntu 18, trying to make zram
to use lz4
compression.
Tried modifying /usr/bin/init-zram-swapping
file
#!/bin/sh
...........
...........
for i in $(seq ${NRDEVICES}); do
DEVNUMBER=$((i - 1))
echo $mem > /sys/block/zram${DEVNUMBER}/disksize
echo lz4 > /sys/block/zram${DEVNUMBER}/comp_algorithm # <= added this line
mkswap /dev/zram${DEVNUMBER}
swapon -p 5 /dev/zram${DEVNUMBER}
done
But, after rebootzramctl
still shows I'm using lzo
algortihm
NAME ALGORITHM DISKSIZE DATA COMPR TOTAL STREAMS MOUNTPOINT
/dev/zram3 lzo 466M 2.9M 614.2K 1M 4 [SWAP]
/dev/zram2 lzo 466M 2.9M 631.2K 1M 4 [SWAP]
/dev/zram1 lzo 466M 2.9M 536.1K 1020K 4 [SWAP]
/dev/zram0 lzo 466M 3M 610K 1M 4 [SWAP]
I also tried adding adding it inrc.local
, but it throws device already in use warning
, because as far as I know, the change needs to be done before mkswap
and swapon
runs.
This works:
Note: it seems you need to define the compression algorithm before zram size. Set
swapon -p
to priority level100
to use zram actively as it improves performance.