Skip to content

Instantly share code, notes, and snippets.

@chenhengqi
Created May 16, 2021 02:13
Show Gist options
  • Save chenhengqi/bada8ea44290eb1cf3fe9df4d66da676 to your computer and use it in GitHub Desktop.
Save chenhengqi/bada8ea44290eb1cf3fe9df4d66da676 to your computer and use it in GitHub Desktop.
enable swap on linux

Howto

setup

$ sudo fallocate -l 2G /swapfile
$ sudo chmod 600 /swapfile
$ sudo mkswap /swapfile
$ sudo swapon /swapfile

view

$ sudo swapon --show
$ sudo free -h
$ cat /proc/sys/vm/swappiness

modify

$ sudo sysctl vm.swappiness=10
# or edit /etc/sysctl.conf, add `vm.swappiness=10`

remove

$ sudo swapoff -v /swapfile
$ sudo rm /swapfile

Reference

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