Commit 50013705 authored by Vladimir Bashkirtsev's avatar Vladimir Bashkirtsev

zram compression algorithm should be configurable

parent 06ae865a
# The factor is swap/RAM ratio in percents # The factor is swap/RAM ratio in percents
FACTOR=100 FACTOR=100
# The compressor is algorithm to use for compression
COMPRESSOR=lzo-rle
#!/bin/sh #!/bin/sh
FACTOR=66 FACTOR=66
COMPRESSOR=lzo-rle
[ -f /etc/zram ] && source /etc/zram || true [ -f /etc/zram ] && source /etc/zram || true
factor=$FACTOR # percentage factor=$FACTOR # percentage
compressor=$COMPRESSOR # compressor
memtotal=$(grep MemTotal /proc/meminfo | awk ' { print $2 } ') memtotal=$(grep MemTotal /proc/meminfo | awk ' { print $2 } ')
mem_used=$(($memtotal*$factor/100*1024)) mem_used=$(($memtotal*$factor/100*1024))
modprobe -q zram modprobe -q zram
grep -q lzo-rle /sys/block/zram0/comp_algorithm && echo lzo-rle > /sys/block/zram0/comp_algorithm grep -q $compressor /sys/block/zram0/comp_algorithm && echo $compressor > /sys/block/zram0/comp_algorithm
echo $mem_used > /sys/block/zram0/disksize echo $mem_used > /sys/block/zram0/disksize
mkswap /dev/zram0 mkswap /dev/zram0
swapon -p 100 /dev/zram0 swapon -p 100 /dev/zram0
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment