Skip to content

Instantly share code, notes, and snippets.

@katopz
Created April 18, 2016 17:22
Show Gist options
  • Save katopz/07ff91bb14cd88d330aaed2c448ad156 to your computer and use it in GitHub Desktop.
Save katopz/07ff91bb14cd88d330aaed2c448ad156 to your computer and use it in GitHub Desktop.
Setup Ubuntu paging and swap file.
# https://help.ubuntu.com/community/CronHowto
# create script in daily cron folder
nano /etc/cron.hourly/free-mem.sh
# insert below line
# http://www.upubuntu.com/2013/01/how-to-free-up-unused-memory-in.html
# Free Up Unused Memory
sudo sysctl -w vm.drop_caches=3
# page cache, inodes, and dentries
sudo sync && echo 3 | sudo tee /proc/sys/vm/drop_caches
# Create a Swap File
# https://www.digitalocean.com/community/tutorials/how-to-add-swap-on-ubuntu-14-04
sudo fallocate -l 4G /swapfile
ls -lh /swapfile
sudo chmod 600 /swapfile
ls -lh /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
sudo swapon -s
free -m
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment