Contents

Setting up swap

Swapiness

To reduce swap partition/file writes and keep more data in RAM. @dotblogs

1
2
echo 'vm.swappiness = 10' | sudo tee -a /etc/sysctl.conf
sudo sysctl -p            # you should see 'vm.swappiness = 10'

Use Swap file

More flexibility in disk space and partition. @PoP planet

1
2
3
4
5
# Make a 512 MB swapfile.
sudo dd if=/dev/zero of=/swapfile bs=1M count=512
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile

Afterwards add the following line to /etc/fstab.

1
/swapfile none swap defaults 0 0