Skip to content

Instantly share code, notes, and snippets.

Created January 29, 2016 10:01
What would you like to do?
Vagrant/Linux increase swap memory
# Thank you to Jorge Quilcate Otoya for this helpful script
# size of swapfile in megabytes
# does the swap file already exist?
grep -q "swapfile" /etc/fstab
# if not then create it
if [ $? -ne 0 ]; then
echo 'swapfile not found. Adding swapfile.'
fallocate -l ${swapsize}M /swapfile
chmod 600 /swapfile
mkswap /swapfile
swapon /swapfile
echo '/swapfile none swap defaults 0 0' >> /etc/fstab
echo 'swapfile found. No changes made.'
# output results to terminal
df -h
cat /proc/swaps
cat /proc/meminfo | grep Swap
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment