Skip to content

Instantly share code, notes, and snippets.

@stilliard
Last active September 26, 2023 10:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stilliard/00f0278cb98d513fe60d51f9d7c6f96d to your computer and use it in GitHub Desktop.
Save stilliard/00f0278cb98d513fe60d51f9d7c6f96d to your computer and use it in GitHub Desktop.
Setup swap partition
# 2gb example
# ref: https://www.digitalocean.com/community/tutorials/how-to-configure-virtual-memory-swap-file-on-a-vps
cd /var
touch swap.img
chmod 600 swap.img
dd if=/dev/zero of=/var/swap.img bs=2048k count=1000
mkswap /var/swap.img
swapon /var/swap.img
echo "/var/swap.img none swap sw 0 0" >> /etc/fstab
sysctl -w vm.swappiness=10
free # to check it's worked
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment