piframe/docs/swap.md

1.2 KiB

swap

zram swap config

Please Note: This sets up a zram swap config. It uses RAM for swap. You should be able to use this if you have >=2Gb of RAM, be sure to keep an eye on your RAM use over time just in case this causes problems. See the munin docs for details on how to monitor RAM use over time.

The below will setup 5% of the system memory as zram backed swap.


sudo -sHu root
git clone https://github.com/StuartIanNaylor/zram-swap-config /opt/zram-swap-config
cd /opt/zram-swap-config
chmod +x install.sh
./install.sh

nano -w /etc/zram-swap-config.conf
MEM_FACTOR=5
SWAPPINESS=1

systemctl reboot

sudo -sHu root
zramctl
cat /proc/sys/vm/swappiness
htop / top to see swap is available

Standard swap file

Please Note: This sets up a standard swap file and can cause your sd card to wear out faster

The below commands will setup 1Gb of swap space as a file on the root filesystem and activate it for use.


sudo -sHu root /bin/bash
mkdir /swap
chattr +C /swap
fallocate -l 1024M /swap/swap.1
chmod 600 /swap/swap.1
mkswap /swap/swap.1
echo 'vm.swappiness=1' > /etc/sysctl.d/99-swap.conf
echo "/swap/swap.1 none swap defaults 0 0" >> /etc/fstab
swapon -a