Skip to content

Instantly share code, notes, and snippets.

@vpnwall-services
Created September 12, 2023 08:24
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save vpnwall-services/7f6c2844038e5bd514718a02ea911542 to your computer and use it in GitHub Desktop.
Save vpnwall-services/7f6c2844038e5bd514718a02ea911542 to your computer and use it in GitHub Desktop.
[SWAP 101] Swap 101 #linux #swap #101

SWAP 101

  • Allocate swap sudo fallocate -l 1G /swapfile

  • Alternate allocation sudo dd if=/dev/zero of=/swapfile bs=1024 count=1048576

  • Perms sudo chmod 600 /swapfile

  • Setup swap sudo mkswap /swapfile

  • Enable swap sudo swapon /swapfile

  • /etc/fstab entry /swapfile swap swap defaults 0 0

  • Show swap sudo swapon --show

  • Adjust swapiness #60 good for all, put lower value for production servers cat /proc/sys/vm/swappiness

  • Setup swapiness sudo sysctl vm.swappiness=10

  • /etc/sysctl.conf vm.swappiness=10

  • Remove swap sudo swapoff -v /swapfile

  • Delete swap file sudo rm /swapfile

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment