Skip to content

Instantly share code, notes, and snippets.

@soekarmana
Forked from dgoguerra/create-swapfile.md
Last active June 30, 2023 01:03
Show Gist options
  • Save soekarmana/a5e489cf278176cd70ee5ef2cdf2f923 to your computer and use it in GitHub Desktop.
Save soekarmana/a5e489cf278176cd70ee5ef2cdf2f923 to your computer and use it in GitHub Desktop.
create swapfile in ubuntu

Taken from a DigitalOcean tutorial.

Create and enable swapfile:

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment