Skip to content

Instantly share code, notes, and snippets.

@ahmadawais
Last active March 22, 2017 06:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ahmadawais/6290f7be0f717e63ee3f3bc821e0d1f4 to your computer and use it in GitHub Desktop.
Save ahmadawais/6290f7be0f717e63ee3f3bc821e0d1f4 to your computer and use it in GitHub Desktop.
DevOps: Setup swap file for better memory management | Ubuntu 16.04 | EasyEngine
#! /usr/bin/env bash
swapoff -a
dd if=/dev/zero of=/swapfile bs=1M count=1024
chmod 600 /swapfile
mkswap /swapfile
swapon /swapfile
# nano /etc/fstab
#st /etc/fstab
# Add this line at the bottom
#/swapfile none swap sw 0 0
echo "/swapfile none swap sw 0 0" >> /etc/fstab
# Now if you run out of RAM, it will use SWAP instead (SSD drive as temporary RAM)
# nano /etc/sysctl.conf
st /etc/sysctl.conf
# Add or Update if present the following
# vm.swappiness = 10
# vm.vfs_cache_pressure = 50
# Finally then push the updates for sysctl
sudo sysctl -p
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment