Skip to content

Instantly share code, notes, and snippets.

@vdw
Last active August 29, 2015 14:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vdw/4f90e25aff0beba8b2de to your computer and use it in GitHub Desktop.
Save vdw/4f90e25aff0beba8b2de to your computer and use it in GitHub Desktop.
Create a swap file on CentOS 6.5

Check for existing swap files

swapon -s

Create swap file with 1024k size

sudo dd if=/dev/zero of=/swapfile bs=1M count=1024

sudo mkswap /swapfile

chown root:root /swapfile

chmod 0600 /swapfile

sudo swapon /swapfile

In case you want to make it permanent

sudo nano /etc/fstab

And add:

/swapfile swap swap defaults 0 0

Set swappiness

sysctl vm.swappiness=10

make it permanent

sudo nano /etc/sysctl.conf

change

vm.swappiness=10

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