-
-
Save nozzlegear/03a297084885a043e9e93afb83cd6e62 to your computer and use it in GitHub Desktop.
Quick and easy script to setup swap
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/sh | |
# createswap.sh | |
# creates swap file. | |
# Optionally specify size (e.g. 1024M) | |
# | |
# <[email protected]> | |
if [ $1 ]; then | |
SWAP_SIZE=$1 | |
else | |
echo "No swap size specified." | |
exit 1; # fail | |
fi | |
echo "Creating swap file with size of $SWAP_SIZE" | |
fallocate -l $SWAP_SIZE /swap | |
mkswap /swap | |
chmod 600 /swap | |
swapon /swap | |
sed -i -e '$a/swap none swap sw 0 0' /etc/fstab | |
sysctl vm.swappiness=10 | |
sed -i -e '$avm.swappiness=10' /etc/sysctl.conf |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment