Make zram amount configurable with ZRAM_SIZE

Change-type: patch
This commit is contained in:
Alexis Svinartchouk 2020-11-17 11:55:43 +01:00
parent 32bd9efa11
commit ce2acdca06

View File

@ -1,13 +1,13 @@
#!/bin/bash #!/bin/bash
DEVICE=/dev/zram0 DEVICE=/dev/zram0
SIZE=1G ${ZRAM_SIZE:=1G}
CURRENT_SIZE=$(zramctl --raw --noheadings --output DISKSIZE $DEVICE) CURRENT_SIZE=$(zramctl --raw --noheadings --output DISKSIZE $DEVICE)
if [ $CURRENT_SIZE != $SIZE ]; then if [ $CURRENT_SIZE != $ZRAM_SIZE ]; then
swapoff $DEVICE swapoff $DEVICE
zramctl $DEVICE --algorithm lz4 --size $SIZE zramctl $DEVICE --algorithm lz4 --size $ZRAM_SIZE
mkswap $DEVICE mkswap $DEVICE
swapon $DEVICE swapon $DEVICE
fi fi