Last active
January 7, 2019 14:57
-
-
Save jamesnguyen101/af5af388c363a7b1dbff42ada6c9e445 to your computer and use it in GitHub Desktop.
make 4G swap on CentOS
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 | |
SWAP_SIZE=4G | |
echo "create $SWAP_SIZE swap" | |
# on centos 6 | |
#fallocate -l $SWAP_SIZE /swapfile | |
# on centos 7 | |
dd if=/dev/zero of=/swapfile count=4096 bs=1MiB | |
echo "enable swap" | |
chmod 600 /swapfile | |
mkswap -f /swapfile | |
swapon /swapfile | |
swapon -s | |
free -h | |
echo "add swapfile into fstab" | |
echo "/swapfile swap swap sw 0 0" >> /etc/fstab | |
echo "swap setting" | |
echo "vm.swappiness = 10" >> /etc/sysctl.conf | |
echo "vm.vfs_cache_pressure = 50" >> /etc/sysctl.conf | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment