Created
February 24, 2020 03:09
-
-
Save bugb/4ff859bf1f3e3bee26bcea5b787d65d1 to your computer and use it in GitHub Desktop.
swap.sh
This file contains hidden or 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/sh | |
set -eu | |
sudo fallocate -l 2G /swapfile | |
ls -lh /swapfile | |
sudo chmod 600 /swapfile | |
sudo mkswap /swapfile | |
sudo swapon /swapfile | |
sudo swapon --show | |
free -h | |
sudo cp /etc/fstab /etc/fstab.bak | |
sudo cp /etc/sysctl.conf /etc/sysctl.conf.old | |
echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab | |
echo 'vm.swappiness=10' | sudo tee -a /etc/sysctl.conf | |
sudo sysctl -p |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment