Skip to content

Instantly share code, notes, and snippets.

@Tiryoh
Created July 12, 2019 14:41
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Tiryoh/9c4ee1e8713d91b156863e896215ad55 to your computer and use it in GitHub Desktop.
Save Tiryoh/9c4ee1e8713d91b156863e896215ad55 to your computer and use it in GitHub Desktop.
create 4GB swapfile on Linux
#!/usr/bin/env bash
set -eu
sudo dd if=/dev/zero of=/var/swapfile bs=1M count=4096
sudo mkswap /var/swapfile
sudo chmod 600 /var/swapfile
sudo swapon /var/swapfile
sudo cat /proc/swaps
echo "/var/swapfile swap swap defaults 0 0" | sudo tee -a /etc/fstab
@Tiryoh
Copy link
Author

Tiryoh commented Jul 12, 2019

Usage

curl -SsfL https://git.io/create_4gbswapfile | bash

@davidpeach
Copy link

Thanks for this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment