🔍 See Original Answer on Ask Ubuntu 🔗
Can you have too much swap?
April 1, 2018
Edited: April 8, 2018
November 24, 2022
Copy to clipboard: false
How much SWAP does hibernation really need?
It’s a misconception that you need RAM x 2 for SWAP size when you use hibernation. The swap size needs to be the size of used RAM not Installed RAM. Generally swap size needs to be 2/5th of installed RAM. To find out the bare-minimum amount of RAM needed for use:
$ cat /sys/power/image_size 3153907712
On this 8 GB RAM machine 3 GB minimum is needed to hibernate.
You can tweak the values in
image_size for a smaller swap size with risk of failure. You can tweak it for a larger swap size and possibly speeding up the hibernation speed.
16 MB RAM in 1995, different rules for 16 GB RAM in 2018
In the days when you had 16 MB Ram, x 2 for 32 MB swap on your 720 MB hard drive made sense. A little RAM and HDD history in this 1995 Washington Post article.
23 years later some technical articles from that 1995 (although I didn’t find any) might be found to mislead new users. I did however find a 2007 article recommending SWAP = RAM x 2.
Back in 1995 32 MB Swap out of 760 MB HDD was 4% of HDD. Indeed the swap partition may have been used a lot in 1995. Today in 2018, 16 GB RAM x 2 for 32 GB SWAP on your 256 GB SSD doesn’t make the same sense as it is taking 13% of SSD. Today my 8 GB SWAP partition isn’t being used at all unless I force it to fill it up when testing OOM-Killer: Google Chrome will take up my memory to the point where it causes my computer to freeze to a near halt. What can I do to prevent this?.