1

I am going to remake a server with Ubuntu 20.04

It will have 6 GB of RAM, a 20 GB SSD for the operating system, and a 100 GB SSD for data.

Should we make a SWAP partition ?

If so, how many GB are needed ?

Thank you

Mathieu
  • 35
  • 1
  • 7
  • It depends on what the server is used for and what is the memory usage profile of your applications. Generally you should install enough memory so that swapping isn't needed during normal operations, because swap is slow. – Tero Kilkanen Aug 12 '20 at 06:11

1 Answers1

-1

It is not a mandatory requirement to have a swap partition and the system will operate without it, however, it is recommended to have one.

There are many different formulas and methods for calculating how much swap space you will need. Some say 1.5x your RAM, some say 2x your RAM, and some give a fixed amount (e.g. 8GB). You will need to assess the intended purpose for the system, what type of applications you intend to run, and the resource usage of the system.

Now, this part is purely my 2c here. If you have 6GB, I'd suggest a 12GB swap partition. This will allow the system enough space to dump the RAM into swap and some overhead.

Christopher H
  • 338
  • 2
  • 16
  • 1
    "SSDs have a limited number of write cycles; it is not recommended to accommodate a swap partition or a swap file (see The swap partition or SWAP)." https://doc.ubuntu-fr.org/swap – Mathieu Aug 11 '20 at 22:23
  • Ok, so if you know you shouldn't use a swap partition on an SSD, what is the basis to your question? And my question did not recommend only using a swap partition on an SSD, it just recommended using one. – Christopher H Aug 11 '20 at 22:26
  • I just saw the article and am looking for confirmation, maybe it is outdated. I only have SSDs on my server. – Mathieu Aug 11 '20 at 22:30
  • If you really wanted a swap space, you could purchase a small 1TB disk, partition it with a 12GB swap partition, and use the rest for long-term storage? Otherwise I would look at upgrading the RAM to 8-16GB. – Christopher H Aug 11 '20 at 22:32
  • So if I increase the RAM memory, I no longer need the SWAP partition? RAM memory is more efficient than SWAP partition? It is better to have more RAM or a SWAP partition? Thank you – Mathieu Aug 11 '20 at 22:36
  • Swap space is designed to be used when system RAM is full, by moving inactive pages in memory to swap. If you have more than enough RAM to meet your requirements, then you would never use swap space. – Christopher H Aug 11 '20 at 23:01