What should my swap size be if I have 32GB of RAM? [duplicate]

I am new to Linux and want to install ubuntu on a computer that has 32GB of RAM. I've read a lot about the recommended size of swap for people with much smaller RAM capacity, but nothing for my size. Can anyone help me? Thank you, I really appreciate your time!

Thanks for all the input. I think I have a better understanding of this issue regarding swap. Some of the answers to my question said it depended also on other specifications as well. I have 32GB of RAM as stated above, a 1TB SSD(main drive), and a 2TB regular hard drive, and an i7 CPU. I only do every day tasks, no server or rendering. At this point I think I will refrain from using hibernation.


Solution 1:

If you want hibernation to work, it has to save everything in RAM to swap space so that it can be restored when the computer is turned on again, so you'd need at least 32 GB of swap space.

If you don't care about hibernation, unless you plan to use more than 32 GB on a regular basis, a small amount like 4 GB or 8 GB would be fine for now. Swap space can be resized later.

Solution 2:

Quoting from Centos,

Swap space in Linux is used when the amount of physical memory (RAM) is full. If the system needs more memory resources and the RAM is full, inactive pages in memory are moved to the swap space. While swap space can help machines with a small amount of RAM, it should not be considered a replacement for more RAM. Swap space is located on hard drives, which have a slower access time than physical memory.

If you're using Ubuntu as your primary OS and have 32GB, you need little to no swap space if you use Ubuntu for normal day-to-day tasks and not big rendering, server running, etc.

The reason why you've read about using swap space for lower levels of RAM is because in that case, swap space is used to fill in for the lack of RAM that they have. In your case with 32GB, and assuming that you're not using Ubuntu for really resource-heavy tasks, I would recommend 4 GB to 8 GB.