Skip to content

Instantly share code, notes, and snippets.

@afeijo
Last active November 17, 2019 03:11
Show Gist options
  • Save afeijo/0da54f9c5f87744329aa16cd23cb759f to your computer and use it in GitHub Desktop.
Save afeijo/0da54f9c5f87744329aa16cd23cb759f to your computer and use it in GitHub Desktop.
# this works for debian, ubuntu and similar
sudo fallocate -l 2G /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
sudo cp /etc/fstab /etc/fstab.bak
echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab
@afeijo
Copy link
Author

afeijo commented Jan 30, 2019

To assign the swapfile size with the same RAM total size:

sudo fallocate -l $(grep MemTotal /proc/meminfo | awk '{print $2}')000 /swapfile

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