0

I have a computer with 32GB of RAM. I would like to know what is the recommended amount of swap space for optimal performance. I'm using Ubuntu and I don't use hibernation. Should I still create a swap partition or file? If yes, how large should it be?

Thank you!

1 Answers1

2

If you have 32 GB of RAM, chances are your system will never use all of it and therefore will never use the swap partition.

However, if your system has 32 GB of RAM, it should also have a hard drive with hundreds of GB of storage, so allocating a couple of GB of swap won't hurt and will provide an extra layer of stability in case a buggy program misuses the RAM. Ubuntu automatically creates a 2 GB swap file, thus giving us an indication that it's advisable to have some swap space.

Everyone has a different opinion on the ideal swap size, and even the major Linux distributions don't have the same swap size guidelines, depending on whether the swap should be on a partition or a file.

In my case, I prefer to use a partition, but in terms of usability, there's no difference between using a file or a partition in terms of efficiency.

Regarding size, if the RAM is less than 1 GB, the swap size is recommended to be at least equal to the RAM size and at most twice the RAM size. If the RAM is greater than 1 GB, the swap size should be at least equal to the square root of the RAM size and at most twice the RAM size. If hibernation is used, the swap size should be equal to the RAM size plus the square root of the RAM size.

For 32 GB of RAM, I estimate that 6 GB of swap if you don't hibernate and 38 GB of swap if you hibernate, in a partition or file, should be sufficient.

kyodake
  • 17,808