Skip to content

Instantly share code, notes, and snippets.

@roramirez
Created July 8, 2016 22:46
Show Gist options
  • Save roramirez/5d6ce6933186d114a3815ef5c915b01a to your computer and use it in GitHub Desktop.
Save roramirez/5d6ce6933186d114a3815ef5c915b01a to your computer and use it in GitHub Desktop.
Create a swap file
fallocate -l 4G /swapfile
chmod 600 /swapfile
mkswap /swapfile
swapon /swapfile
echo "/swapfile none swap sw 0 0" >> /etc/fstab
@roramirez
Copy link
Author

In Centos need use

sudo dd if=/dev/zero of=/swapfile count=4096 bs=1MiB

instead of
fallocate -l 4G /swapfile

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