Skip to content

Instantly share code, notes, and snippets.

@pvilas
Created June 18, 2023 12:26
Show Gist options
  • Save pvilas/dc1bc38285c8c31ce25716359ff171d6 to your computer and use it in GitHub Desktop.
Save pvilas/dc1bc38285c8c31ce25716359ff171d6 to your computer and use it in GitHub Desktop.
Create swap file on Ubuntu
# taken from https://www.linode.com/docs/guides/how-to-increase-swap-space-in-ubuntu/
sudo swapon --show # show if there is any swap area
free -h
sudo fallocate -l 2G /swapfile # allocate the sw file
sudo chmod 600 /swapfile # only sudo can write
sudo mkswap /swapfile # designate file as swap
sudo swapon /swapfile # activate
sudo swapon --show # show if the file is activated
free -h # show swap
sudo cp /etc/fstab /etc/fstab.bak # backup stab file
sudo vi /etc/fstab # edit fstab
/swapfile swap swap defaults 0 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment