Last active
May 13, 2016 07:58
-
-
Save markuman/49774656493f95d8ea0479774d12b320 to your computer and use it in GitHub Desktop.
zram
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
zr=$(lsmod|grep zram) | |
if [ -z "$zr" ]; then | |
echo "load zram" | |
modprobe zram num_devices=5 | |
fi | |
if (("$#" == 0)); then | |
echo lz4 > /sys/block/zram0/comp_algorithm && | |
echo 4G > /sys/block/zram0/disksize && | |
mkswap --label zram0 /dev/zram0 && | |
swapon --priority 100 /dev/zram0 | |
elif [ "$1" = "off" ]; then | |
echo "unload zram" | |
swapoff -a && | |
rmmod zram | |
else | |
for n in `seq 2 "$1"` | |
do | |
echo lz4 > /sys/block/zram"$n"/comp_algorithm && | |
echo 4G > /sys/block/zram"$n"/disksize && | |
mkswap --label zram"$n" /dev/zram"$n" && | |
swapon --priority 100 /dev/zram"$n" | |
done | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment