Skip to content

Instantly share code, notes, and snippets.

@noherczeg
Last active August 29, 2015 14:13
Show Gist options
  • Select an option

  • Save noherczeg/0250cf95734342f4035e to your computer and use it in GitHub Desktop.

Select an option

Save noherczeg/0250cf95734342f4035e to your computer and use it in GitHub Desktop.
vps swap creation put simple
# tested on ubuntu 14.04
# ------------------------------------------
# CREATE SWAP:
# ------------------------------------------
$ swapon -s
$ free -m
$ sudo fallocate -l 4G /swapfile
$ ls -lh /swapfile
# ------------------------------------------
# ENABLE SWAP:
# ------------------------------------------
$ chmod 600 /swapfile
$ ls -lh /swapfile
$ sudo mkswap /swapfile
$ sudo swapon /swapfile
$ sudo swapon -s
$ free -m
# ------------------------------------------
# PERMA SWAP:
# ------------------------------------------
$ sudo nano /etc/fstab
# add to last line:
# /swapfile none swap sw 0 0
# ------------------------------------------
# TWEAKS:
# ------------------------------------------
$ sudo sysctl vm.swappiness=10
$ sudo nano /etc/sysctl.conf
# add to last line:
# vm.swappiness=10
$ sudo sysctl vm.vfs_cache_pressure=50
$ sudo nano /etc/sysctl.conf
# add to last line:
# vm.vfs_cache_pressure = 50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment