Skip to content

Instantly share code, notes, and snippets.

@shoemoney
Created September 27, 2021 12:49
Show Gist options
  • Save shoemoney/92950e68235048f9545b1bbe0bb171bd to your computer and use it in GitHub Desktop.
Save shoemoney/92950e68235048f9545b1bbe0bb171bd to your computer and use it in GitHub Desktop.
Create Swap Partition and Activate On Amazon Linux 2
#first create the file this will make a 4gb file. do 20 count for 2gb etc..
sudo dd if=/dev/zero of=/swapfile bs=128M count=32
chmod 600 /swapfile
#format the file properly with mkswap
sudo mkswap /swapfile
#tell your system to activate it
swapon /swapfile
#test swap file
swapon -s
#if no errors add to fstab so it auto mounts:
echo '/swapfile swap swap defaults 0 0' > /etc/fstab
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment