Skip to content

Instantly share code, notes, and snippets.

@sofianhw
Created February 27, 2023 07:28
Show Gist options
  • Save sofianhw/7d31762c64f43a9a7e4efa718acaccca to your computer and use it in GitHub Desktop.
Save sofianhw/7d31762c64f43a9a7e4efa718acaccca to your computer and use it in GitHub Desktop.
swap-linux
# make swapfile
sudo fallocate -l 2G /swapfile
sudo chmod 600 /swapfile
# mark as swap space
sudo mkswap /swapfile
# enable swap file
sudo swapon /swapfile
# make it permanent
echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab
# adjust swappiness /etc/sysctl.conf
echo 'vm.swappiness=25' | sudo tee -a /etc/sysctl.conf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment