Skip to content

Instantly share code, notes, and snippets.

@jbutko
Last active December 14, 2022 10:02
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 jbutko/27a5340e47d44ff06f3988f4f24eae97 to your computer and use it in GitHub Desktop.
Save jbutko/27a5340e47d44ff06f3988f4f24eae97 to your computer and use it in GitHub Desktop.
Resize swap
# Resize Swap to 8GB
# Turn swap off
# This moves stuff in swap to the main memory and might take several minutes
sudo swapoff -a
# if it won't work issue:
# sudo /sbin/swapoff
# Create an empty swapfile
# Note that "1G" is basically just the unit and count is an integer.
# Together, they define the size. In this case 8GB.
sudo dd if=/dev/zero of=/swapfile bs=1G count=8
# Set the correct permissions
sudo chmod 0600 /swapfile
sudo mkswap /swapfile # Set up a Linux swap area
sudo swapon /swapfile # Turn the swap on
# Check if it worked
grep Swap /proc/meminfo
# via https://askubuntu.com/a/1177939/637548
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment