Skip to content

Instantly share code, notes, and snippets.

@JosephKu
Last active July 14, 2022 14:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JosephKu/4f81261c8b0aec10d416 to your computer and use it in GitHub Desktop.
Save JosephKu/4f81261c8b0aec10d416 to your computer and use it in GitHub Desktop.
#!/bin/sh
echo "Creating Swap file... (Size: 2GB)"
#sudo dd if=/dev/zero of=/var/swapfile bs=1M count=2048 &&
sudo fallocate -l 2G /var/swapfile && # A new and effective way since Linux 2.6.23
sudo chmod 600 /var/swapfile &&
sudo mkswap /var/swapfile &&
echo "/var/swapfile none swap defaults 0 0" | sudo tee -a /etc/fstab
sudo swapon -a
echo "Done. Happy swapping!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment