Skip to content

Instantly share code, notes, and snippets.

@christianascone
Last active November 11, 2020 09:02
Show Gist options
  • Save christianascone/470da640c89034d2fa403fdb4dd210f8 to your computer and use it in GitHub Desktop.
Save christianascone/470da640c89034d2fa403fdb4dd210f8 to your computer and use it in GitHub Desktop.
Create and enable/disable a swap file
#!/bin/bash
# Create 1GB swap file (change count if needed)
sudo dd if=/dev/zero of=/swapfile bs=1G count=1
# Fix permissions
sudo chmod 600 /swapfile
# Make swap with given file
sudo mkswap /swapfile
# Enable swap
sudo swapon /swapfile
# Check Swap
sudo swapon -s
#!/bin/bash
sudo swapoff -a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment