Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@alex-shpak
Last active July 20, 2022 11:03
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 alex-shpak/1deada2654dcd642aac2 to your computer and use it in GitHub Desktop.
Save alex-shpak/1deada2654dcd642aac2 to your computer and use it in GitHub Desktop.
swapon.sh /swap 2G
#!/bin/bash
FILE=${1-"/swapfile"}
SIZE=${2-"4G"}
fallocate -l $SIZE $FILE
chmod 600 $FILE
ls -lh $FILE
mkswap $FILE
swapon $FILE
swapon -s
echo "$FILE none swap sw 0 0" >> /etc/fstab
# https://www.digitalocean.com/community/tutorials/how-to-add-swap-on-ubuntu-14-04
# $wget https://gist.githubusercontent.com/alex-shpak/1deada2654dcd642aac2/raw/6f6b1b6ab29286e6286907e9818cc02b0110b7ef/swapon.sh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment