post_boot: Set zRam disk size to 50% of RAM size.

Set zRam disk size to 50% of RAM size for non-Go devices.

Change-Id: Ifd015f7827db8ed9388833ec09627898e20fd209
This commit is contained in:
Vijay Dandiga 2019-10-15 16:59:44 +05:30 committed by Max Weffers
parent 1d511d727b
commit b68ab8e7a9
No known key found for this signature in database
GPG key ID: 795F73D22FB93FAE

View file

@ -340,11 +340,15 @@ function configure_zram_parameters() {
# Zram disk - 75% for Go devices.
# For 512MB Go device, size = 384MB, set same for Non-Go.
# For 1GB Go device, size = 768MB, set same for Non-Go.
# For >1GB and <=3GB Non-Go device, size = 1GB
# For >3GB and <=4GB Non-Go device, size = 2GB
# For >4GB Non-Go device, size = 4GB
# For >=2GB Non-Go devices, size = 50% of RAM size. Limit the size to 4GB.
# And enable lz4 zram compression for Go targets.
RamSizeGB=`echo "($MemTotal / 1048576 ) + 1" | bc`
zRamSizeBytes=`echo "$RamSizeGB * 1024 * 1024 * 1024 / 2" | bc`
if [ $zRamSizeBytes -gt 4294967296 ]; then
zRamSizeBytes=4294967296
fi
if [ "$low_ram" == "true" ]; then
echo lz4 > /sys/block/zram0/comp_algorithm
fi
@ -357,12 +361,8 @@ function configure_zram_parameters() {
echo 402653184 > /sys/block/zram0/disksize
elif [ $MemTotal -le 1048576 ]; then
echo 805306368 > /sys/block/zram0/disksize
elif [ $MemTotal -le 3145728 ]; then
echo 1073741824 > /sys/block/zram0/disksize
elif [ $MemTotal -le 4194304 ]; then
echo 2147483648 > /sys/block/zram0/disksize
else
echo 4294967296 > /sys/block/zram0/disksize
echo $zRamSizeBytes > /sys/block/zram0/disksize
fi
mkswap /dev/block/zram0
swapon /dev/block/zram0 -p 32758