firefly-rk3399 | X.Org | accelerati

      1 mon ago

    firefly-rk3288 | turbo-mode

      7 mon ago

   firefly-rk3288 | 4.4.50 | slackware

      7 mon ago

   upstream | virualbox

      7 mon ago

   get_version | git | mercurial

      7 mon ago

   slackware | rc.zram

      7 mon ago

   firefly-rk3288 | 4.4.41 | slackware

      8 mon ago

    firefly-rk3288 | 4.x | slackware |

      9 mon ago

   slackware | X Server 1.19.0 | armsoc

      9 mon ago

   u-boot | mainstream | firefly-rk3288

      9 mon ago

embedded link

slackware | rc.zram

  29 янв 2017 03:06:23      1.16 kb      never
raw

  AsciiDoc


#!/bin/sh

FRACTION=50

MEMORY=$(grep "MemTotal" /proc/meminfo | awk '{print $2*1024}')
CPUS=$(grep -c processor /proc/cpuinfo)
SIZE=$(( MEMORY * FRACTION / 100 / CPUS ))


start() {
    param=$(modinfo zram | grep num_devices|cut -f2 -d:|tr -d ' ')
    stop
    modprobe zram $param=$CPUS
    echo "Startting zram $CPUS parts"
    for n in $(seq $CPUS); do
        i=$((n - 1))
        echo lz4 > /sys/block/zram$i/comp_algorithm
        echo $SIZE > /sys/block/zram$i/disksize
        mkswap /dev/zram$i 2>&1>/dev/null
        swapon /dev/zram$i -p 10
    done
}

stop() {
    for n in $(seq $CPUS); do
        i=$((n - 1))
        [[ $(grep "/dev/zram$i" /proc/swaps) ]] && swapoff /dev/zram$i
    done
    wait
    sleep .5
    modprobe -r zram
}

restart() {
#    for n in $(seq $CPUS); do
#        i=$((n - 1))
#        echo 1 > /sys/block/zram$i/reset
#    done
    stop
    start
}


case "$1" in
  start)
    start
    ;;
  stop)
    stop
    ;;
  restart)
    restart
    ;;
  *)
    echo "Usage: $0 (start|stop|restart)"
    ;;
esac