Created
July 7, 2018 01:07
-
-
Save h3nr1ke/8a23d435bda6e132ef419fd0f97802fa to your computer and use it in GitHub Desktop.
Add a swap memory partition to your ubuntu 16.04 server
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
#!/bin/bash | |
#-- create the swap | |
sudo fallocate -l 1G /swapfile | |
#-- change permission | |
sudo chmod 600 /swapfile | |
#-- do the swap | |
sudo mkswap /swapfile | |
#-- add the swapp to be permanent | |
echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab | |
#-- add configs to swap | |
echo 'vm.swappiness=10' | sudo tee -a /etc/sysctl.conf | |
echo 'vm.vfs_cache_pressure=50' | sudo tee -a /etc/sysctl.conf | |
echo "Swap created" | |
#-- show the info | |
sudo swapon --show | |
free -h |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment