echo "IyEvYmluL2Jhc2gKY29yZXM9JChucHJvYyAtLWFsbCkKbW9kcHJvYmUgenJhbSBudW1fZGV2aWNlcz0kY29yZXMKCnN3YXBvZmYgLWEKCnRvdGFsbWVtPWBmcmVlIHwgZ3JlcCAtZSAiXk1lbToiIHwgYXdrICd7cHJpbnQgJDJ9J2AKbWVtPSQoKCAoJHRvdGFsbWVtIC8gJGNvcmVzKSogMTAyNCApKQoKY29yZT0wCndoaWxlIFsgJGNvcmUgLWx0ICRjb3JlcyBdOyBkbwogIGVjaG8gJG1lbSA+IC9zeXMvYmxvY2svenJhbSRjb3JlL2Rpc2tzaXplCiAgbWtzd2FwIC9kZXYvenJhbSRjb3JlCiAgc3dhcG9uIC1wIDUgL2Rldi96cmFtJGNvcmUKICBsZXQgY29yZT1jb3JlKzEKZG9uZQo=" | base64 --decode > /usr/bin/zram.sh
chmod +x /usr/bin/zram.sh
Add '/usr/bin/zram.sh &' before 'exit 0' in 'rc.local':
cat /etc/rc.local
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.
# Print the IP address
_IP=$(hostname -I) || true
if [ "$_IP" ]; then
printf "My IP address is %s\n" "$_IP"
fi
/usr/bin/zram.sh &
exit 0
Appendix. The content of zram.sh:
#!/bin/bash
cores=$(nproc --all)
modprobe zram num_devices=$cores
swapoff -a
totalmem=`free | grep -e "^Mem:" | awk '{print $2}'`
mem=$(( ($totalmem / $cores)* 1024 ))
core=0
while [ $core -lt $cores ]; do
echo $mem > /sys/block/zram$core/disksize
mkswap /dev/zram$core
swapon -p 5 /dev/zram$core
let core=core+1
done
Related:https://www.kernel.org/doc/Documentation/blockdev/zram.txt
No comments:
Post a Comment