3

My Swap space is currently set to 2 GB. How do I increase it?

Also I'm running with an SSD and have 16GB of RAM. What is the Max Memory I can set the swap file to?

marked as duplicate by muru, Fabby, Zanna, Sergiy Kolodyazhnyy, Eric Carvalho Aug 21 '18 at 12:15

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • Ubuntu 17.10 has reached EOL on July 19,2018. Please upgrade to a supported version, eg. 18.04 for continuous support. – Kulfy Aug 17 '18 at 18:43
  • if you have 16 gigs of ram why would so much swap be needed? just curious :) – Joshua Besneatte Aug 17 '18 at 20:16
  • A lot of tabs open in Chrome... I'm constantly bouncing between different research topics ... – Ole Aug 18 '18 at 1:16
  • 1
    1) This should be closed as duplicate 2) With 16 GB of RAM it's more than enough even for chrome. 3) Consider trying ramdisk for chrome instead , see askubuntu.com/q/794290/295286 – Sergiy Kolodyazhnyy Aug 19 '18 at 2:40
5

OK - That was a lot less scary than I thought it was going to be. I increased the swap size to 8 GB with the following sequence (Based on the 3rd answer in the linked post - Note that I had to turn off swap first - If you look at your system monitor you will see Ubuntu emptying out your swap space as you run the first command):

sudo swapoff /swapfile
sudo fallocate -l 8G /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile

Verify it:

 sudo swapon --show

Make it permanent:

echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab

Update

This worked great and my laptop stopped freezing due to memory hogging by Chrome. One of the comments asserted that 16GB is enough, and in general I agree, but this is what my situation looks like:

enter image description here

Not the answer you're looking for? Browse other questions tagged or ask your own question.