Hi All,

A few years ago the general rule of thumb for swapping was swap=RAMx2.

Now that seems fairly sensible when ram was smaller than it is today. My new rig arrives tomorrow and with 8gig of ram following the rule of thumb above would mean 16Gig of swap space.

Now with larger disks as well 16Gig of spaces isn't as big as it used to be, but it still seems a smite excessive.

So my question is at what point does a swap partition become unnecessary. I would say that with 8Gig I am rarely going to hammering the memory so hard as to use it all up.

Is a better option to have no swap partition at all and setup swap files as and when you know you are going to be running memory intesive applications? Or perhaps still have the swap partition, but maybe a different ratio such as swap=RAM or swap=RAM/2?

Id appreciate anyones thoughts.

Hi Moncky,

This is something I've been interested in too, and until recently there hasn't been any real "standard" to go by. With as much RAM as you can get into a machine these days, the recommended swap size varies wildly depending on how the machine will be used.

After I read your post, I went searching to see if anyone had come up with any guidelines, and I came across blog post that refers to a table in the RedHat Linux installation manual. This looks pretty reasonable to me. Here's an excerpt:

In years past, the recommended amount of swap space increased linearly with the amount of RAM in the system. But because the amount of memory in modern systems has increased into the hundreds of gigabytes, it is now recognized that the amount of swap space that a system needs is a function of the memory workload running on that system. However, given that swap space is usually designated at install time, and that it can be difficult to determine beforehand the memory workload of a system, we recommend determining system swap using the following table.

Recommended System Swap Space:
4GB of RAM or less a minimum of 2GB of swap space
4GB to 16GB of RAM a minimum of 4GB of swap space
16GB to 64GB of RAM a minimum of 8GB of swap space
64GB to 256GB of RAM a minimum of 16GB of swap space
256GB to 512GB of RAM a minimum of 32GB of swap space

Note that you can obtain better performance by distributing swap space over multiple storage devices, particularly on systems with fast drives, controllers, and interfaces.

The links to the RHEL documentation seem to change on a regular basis, but here's the current link to that page:


I hope this helps!

Hi Gromit,

I did see that table, however that pertains more to a sever setup than a desktop setup. Though does seem reasonable for most usage.

I have been considering how best to setup my new system and in looking into this discovered that suspend to disk is now in a decent state, and has been for some time. It appears though hints, though nothing concrete that I could see, in various articles that suspension of the system to disk is placed in the swap space, which makes sense.

However I guess as it suspends everything in memory that you would be looking at at least SWAP=RAM, though its unlikely that you would be trying to suspend your machine whilst your also hammering your memory.

Suspending a server is something I have never seen done, so I dont expect that on a server with 512GB of ram you would setup 512GB of swap space of course.

Add the after thought so I don't look completely stupid

Good point! I wasn't thinking about suspend. Here's a link that suggests that you need 2x the amount of installed RAM for suspend-to-disk to work.

That page also links to this article, which hints at something else I've read, which is that using a suspend file is an option, instead of using swap.

Further research suggests that the standard swsusp and uswsusp modules might not support suspending to a file (except in the case of a swap file), but TuxOnIce (aka swsusp2) does. I may or may not be more confused than when I started...

I hope this helps!

In another doh moment I haven't taken VM's into account either. So maybe Swap=RAMx1.5 or SWAP=RAMx2.0 is not such a stretch after all.

I guess the lesson to take from this is that you swap allocation depends on what you will be doing with the machine. Which again makes a bundle of sense. Apache Servers won't necessarily require a massive ammount of swap, however a build server may need a more generous amount if there's lots memory access going on. Got to love the flexibility of Linux.

So I reckon I can run with 8Gig memory and will need about 10 - 12 Gig swap space to allow for hibernation and for the running of VM's and hibernating those running VM's

In short it looks like Im possibly going to be wishing I went for the upgrade to 12 Gig of ram after all :P either that or a lobotomy.

Thanks for the links, they look like they will be helpful when it comes to getting suspend working.

No problem, let us know how it goes :) It should work fine in any case, but it's always good to know how best to optimize things, and swap is one of those areas where I don't really know as much as I probably should =P