Last active
September 6, 2016 14:00
-
-
Save czechboy0/ba249dc375dd6335f30f7acd593aa193 to your computer and use it in GitHub Desktop.
Add 4 GB swapspace on Ubuntu 14.04
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
# based on https://www.digitalocean.com/community/tutorials/how-to-add-swap-on-ubuntu-14-04 | |
# run with eval "$(curl -sL https://gist.githubusercontent.com/czechboy0/ba249dc375dd6335f30f7acd593aa193/raw/add_swap.sh)" | |
echo "Starting with swap table:" | |
sudo swapon -s | |
echo "Available space:" | |
df -h | |
echo "Creating a 4GB swap file" | |
sudo fallocate -l 4G /swapfile | |
ls -lh /swapfile | |
sudo chmod 600 /swapfile | |
echo "Enabling swap file" | |
sudo mkswap /swapfile | |
sudo swapon /swapfile | |
echo "Current swap files:" | |
sudo swapon -s | |
echo "Enabling swap for after reboot" | |
echo "/swapfile none swap sw 0 0" >> /etc/fstab | |
echo "Setting swappiness to 10" | |
sudo sysctl vm.swappiness=10 | |
echo "vm.swappiness=10" >> /etc/sysctl.conf | |
echo "Setting cache pressure to 50" | |
sudo sysctl vm.vfs_cache_pressure=50 | |
echo "vm.vfs_cache_pressure = 50" >> /etc/sysctl.conf | |
echo "You might want to reboot now just for good measures :)" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment