Skip to content

Instantly share code, notes, and snippets.

@rchrd2
Last active August 12, 2017 01:18
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save rchrd2/f13bf3f30857d9778512 to your computer and use it in GitHub Desktop.
Save rchrd2/f13bf3f30857d9778512 to your computer and use it in GitHub Desktop.
Create memory swap (virtual memory) on ubuntu
sudo swapon -s
free -m
df -h
# 2G, 4G, etc
sudo fallocate -l 2G /swapfile
ls -lh /swapfile
sudo chmod 600 /swapfile
ls -lh /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
sudo swapon -s
free -m
@rchrd2
Copy link
Author

rchrd2 commented Dec 30, 2014

To make the swap permanent, run:

sudo echo "/swapfile   none    swap    sw    0   0" >> /etc/fstab

@rchrd2
Copy link
Author

rchrd2 commented Dec 30, 2014

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