#!/bin/bash

# ignore zram in dockerenv
if [[ -f /.dockerenv ]]; then
  exit 0
fi

modprobe zram num_devices=4

totalmem=$(free -m | awk '/Mem:/{print $2}')
mem=$(( ($totalmem / 4 / 2)* 1024 * 1024))

for i in `seq 0 3`; do
  if [[ ! -e /dev/zram${i} ]]; then
    echo $mem > /sys/block/zram${i}/disksize
    mkswap /dev/zram${i}
    swapon -p 5 /dev/zram${i}
  fi
done

#!/bin/bash

# ignore zram in dockerenv
if [[ -f /.dockerenv ]]; then
  exit 0
fi

modprobe zram num_devices=4

totalmem=$(free -m | awk '/Mem:/{print $2}')
mem=$(( ($totalmem / 4 / 2)* 1024 * 1024))

for i in `seq 0 3`; do
  echo $mem > /sys/block/zram${i}/disksize
  mkswap /dev/zram${i}
  swapon -p 5 /dev/zram${i}
done

Revert "only create zram if not exists"
Revert "only create zram if not exists"

This reverts commit 61a11498655132cb924abaa5a5cd3f5b1274b529.
