I have a particular server : 50GB SSD for the OS (CentOS) , 128GB of RAM and 320GB SSD for MySQL.

I'm wondering if I really need SWAP? I often read that 2GB is good even with lots of RAM.

This server will be a MySQL database mainly. Is there any good reason for keeping a 2GB SWAP?

  • I don't think I would create a partition for swap on a system with that much memory. I would be tempted to set up one of the tools that create swap-files as-needed. – Zoredache Jan 13 '11 at 22:54
  • I'm inclined to agree with Zoredache but before making a final decision you might consider creating some swap and monitoring it for a while to see if it ever gets used. At least that would take the guesswork out of it. – John Gardeniers Jan 14 '11 at 1:43
  • This topic came up on the Linux Kernel Mailing List back in 2004 - and no doubt will again. KernelTap has the details: kerneltrap.org/node/3202 – Mei Jan 14 '11 at 17:21

If you have any spare disk space -- setup some swapspace there. You can always delete it if longterm stats show you that it's idle in your environment. But when something goes wrong (memory leaks, buggy software, etc.) you will appreciate having high load and be able do debug instead of getting "out of memory" errors and having to reboot.


Last I checked, the general consensus was it was good to have swap to deal with unexpected temporary out of memory conditions. Back in the day we used to provision server swap with 1.5X physical memory, but that was when systems had a lot less memory than they do today.

With a host with that much RAM, I suggest either keeping a small swap space, or set it up with no swap at all, and do some load testing to determine how the machine performs in low memory conditions. If that testing is ok, then don't even set up any swap at all.

Remember you can always set up a swapfile later if you need one.

  • I would strongly suggest against not having swap. By the time you need to set up a swapfile, the system is likely to be unresponsive and the setting up could be near impossible. I would recommend a swap space of 2Gb to 5Gb or so. (PS: I remember the swap rule being 2x or 3x!) – Mei Jan 13 '11 at 22:58

Yes, you need swap space. Speaking generally, some programs (such as Oracle) will not install without swap space present in sufficient quantities. Some operating systems (such as HP-UX - in the past, at least) preallocate swap space based on what is running on your system at the time.

Of course, this is not true (to my knowledge) for Linux itself.

Swap is often used as dump space - so you might want enough to capture a full kernel dump to disk. However, if you don't expect to be doing kernel traces (either yourself or through a support contract) then you could skip having that much space.

  • In doing research, it turns out SAP would not start without having swap 3.5x memory - for Oracle, installation was refused based on swap 2x memory. – Mei Jan 14 '11 at 17:19
  • Wow, one more in the myriad of reasons why Oracle sucks. A db should NEVER be using swap. – psusi Nov 14 '12 at 2:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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