######### ZRAM SWAP ########## # set to "on" to activate. ZRAM_SWAP="on" # If you have several swap devices (or partitions), you may prefer to have # a higher priority for zram_swap. ZRAM_SWAP_PRIORITY=30 # Maybe you could use some extra args while loading zram module. ZRAM_EXTRA_ARGS="" ######## NOTHING TO CHANGE BELOW THIS ########## if [ $ZRAM_SWAP = "on" ]; then modprobe zram $ZRAM_EXTRA_ARGS if grep -wq /dev/zram0 /proc/swaps; then # Normally, this shouldn't be executed if you don't play with rc.local. gprintf "Unloading and reseting zram swap device\n" swapoff /dev/zram0 echo 1 > /sys/block/zram0/reset fi gprintf "Sizing zram swap device\n" FREE_MEM=`free -t -m | egrep Mem | awk {'print $2'}` # Swap size = 25% of free memory; ZRAM_SWAP_SIZE=$(($FREE_MEM/4)) echo $(($ZRAM_SWAP_SIZE * 1024 * 1024)) > /sys/block/zram0/disksize gprintf "Activating zram swap device\n" mkswap /dev/zram0 swapon -p $ZRAM_SWAP_PRIORITY /dev/zram0 success;echo fi ######### /ZRAM SWAP ##########