Skip to content

Instantly share code, notes, and snippets.

@phongvh
Created March 24, 2020 07:15
Show Gist options
  • Save phongvh/abef85ab61578a949fdbe6382d5a6767 to your computer and use it in GitHub Desktop.
Save phongvh/abef85ab61578a949fdbe6382d5a6767 to your computer and use it in GitHub Desktop.
#!/bin/sh
echo "Create a 4 gigabyte swapfile"
sudo fallocate -l 4G /swapfile
echo "Secure the swapfile by restricting access to root"
sudo chmod 600 /swapfile
echo "Mark the file as a swap space"
sudo mkswap /swapfile
echo "Enable the swap"
sudo swapon /swapfile
echo "Persist swapfile over reboots"
echo "/swapfile none swap sw 0 0" | sudo tee -a /etc/fstab
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment