westbywest / robin-mesh-v2

Derivative of the ROBIN Mesh Firmware http://wiki-robin.meshroot.com/
4 stars 19 forks source link

Reduce swappiness #12

Open westbywest opened 10 years ago

westbywest commented 10 years ago

zram active on all nodes, but recommend tweaking the 'swappiness' valueto 0 - the default is 65. the higher the number, the more likely the kernel swaps out. if set to 0 zram is only used if the is no other possibility. of course: if swapping begins, the box freezes for some seconds but it does not die.

the kernel likes to swap out processes which are not in use, e.g. uhttpd or dropbear. olsrd or other active processes are very unlikely to be swapped - the kernel is smart somehow 8-)

westbywest commented 10 years ago

Can do this with custom.sh:

# Only swap if no alternative
echo 0 > /proc/sys/vm/swappiness
/sbin/reboot
westbywest commented 10 years ago
# Set some params for ROBIN v2 nodes
ROBIN_VER=$(cut -d "-" -f1 /etc/robin_version | cut -d "_" -f1 | tr -cd '[0-9]')
if [ $ROBIN_VER -gt 36000 ]; then
        if ! [ "$(grep swappiness /etc/sysctl.conf)" ]; then
                sysctl -w vm.swappiness=0 
                echo 0 > /proc/sys/vm/swappiness
                echo "# Only swap when no alternative" >> /etc/sysctl.conf
                echo "vm.swappiness=0" >> /etc/sysctl.conf
        fi
fi