Last active
August 29, 2015 13:57
-
-
Save cristianbica/9594944 to your computer and use it in GitHub Desktop.
Adds swap to a linux system
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
# for 1G of swap run | |
# curl https://gist.githubusercontent.com/cristianbica/9594944/raw/add_swap.sh | bash -v -s 128M 8 | |
# it will build a swapfile of 1G (8 blocks of 128M) and make it swap | |
BLOCK_SIZE=$1 | |
BLOCKS_COUNT=$2 | |
dd if=/dev/zero of=/swapfile bs=$BLOCK_SIZE count=$BLOCKS_COUNT | |
sudo chown root:root /swapfile | |
sudo chmod 0600 /swapfile | |
mkswap /swapfile | |
swapon /swapfile | |
echo '/swapfile none swap sw 0 0' >> /etc/fstab | |
echo 10 | sudo tee /proc/sys/vm/swappiness | |
echo vm.swappiness = 10 | sudo tee -a /etc/sysctl.conf | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment