wok-6.x diff linux64-zram/stuff/compcache @ rev 23440

linux-zram: autostart
author Pascal Bellard <pascal.bellard@slitaz.org>
date Thu Apr 02 12:22:43 2020 +0200 (2020-04-02)
parents 804a303f31dc
children f1020832b94b
line diff
     1.1 --- a/linux64-zram/stuff/compcache	Thu Nov 28 10:13:55 2019 +0100
     1.2 +++ b/linux64-zram/stuff/compcache	Thu Apr 02 12:22:43 2020 +0200
     1.3 @@ -16,13 +16,17 @@
     1.4        _ '%s is already running.' $NAME
     1.5        exit 1
     1.6      fi
     1.7 +    if [ -z "$SIZE" -o "$SIZE" = "0%" ]; then
     1.8 +      _ '%s disabled in %s.' $NAME '/etc/compcache.conf'
     1.9 +      exit 1
    1.10 +    fi
    1.11      action 'Loading module...'
    1.12      devices=$(awk '/cpu cores/{c=$4} /processor/{p++}
    1.13  	END { if (c>0) p=c; if (p==0) p++; print p }' /proc/cpuinfo)
    1.14      modprobe zram num_devices=$devices &&
    1.15 -    [ -n "$SIZE_KB" ] && for i in $(seq 0 $(($devices-1))); do
    1.16 -	awk "END { print $SIZE_KB * 1024 / $devices }" < /dev/null \
    1.17 -		> /sys/block/zram$i/disksize
    1.18 +    for i in $(seq 0 $(($devices-1))); do
    1.19 +	awk "/MemTotal/ { print \$2 * 1024 * ${SIZE%\%} * / 100 / $devices }" \
    1.20 +		< /proc/meminfo > /sys/block/zram$i/disksize
    1.21      done
    1.22      status
    1.23