Last active
March 22, 2017 06:38
-
-
Save ahmadawais/6290f7be0f717e63ee3f3bc821e0d1f4 to your computer and use it in GitHub Desktop.
DevOps: Setup swap file for better memory management | Ubuntu 16.04 | EasyEngine
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /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