Skip to content

Instantly share code, notes, and snippets.

@jamesbee
Last active August 29, 2015 14:24
Show Gist options
  • Save jamesbee/8b42ba3f9971b76ba531 to your computer and use it in GitHub Desktop.
Save jamesbee/8b42ba3f9971b76ba531 to your computer and use it in GitHub Desktop.
#! /bin/bash
sudo -i
echo "Create '/swapfile'"
fallocate -l "$1G" /swapfile
chmod 600 /swapfile
mkswap /swapfile
swapon /swapfile
echo ""
echo "Swap status:"
swapon -s
echo ""
echo ""
echo "Mem status:"
free -m
echo ""
echo "Mount swap to fstab."
echo '/swapfile none swap sw 0 0' >> /etc/fstab
echo "Set swapniess to 10"
sysctl vm.swappiness=10
echo vm.swappiness=10 >> /etc/sysctl.conf
echo "Set vfs cache pressure to 50"
sysctl vm.vfs_cache_pressure=50
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