Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

Possible Duplicate:
I have 16GB RAM. Do I need 32GB swap?

I wanted to just confirm how much the size of Swap partition should be. Lots of places tell that the swap size should be twice the size of RAM. Somebody also told me that it shouldn't be more than 8 GB.If twice the size of RAM is more than 8 GB how big should the Swap partition be?

share|improve this question

marked as duplicate by Javier Rivera, htorque, RolandiXor, Takkat, Uri Herrera Sep 20 '11 at 3:50

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

4 Answers 4

Excerpt from SOURCE: (Please follow the link and read the source for more information)

Nonsense rule: Twice the size of your main system RAM for Servers

According to OpenBSD FAQ:

Many people follow an old rule of thumb that your swap partition should be twice the size of your main system RAM. This rule is nonsense. On a modern system, that's a LOT of swap, most people prefer that their systems never swap. You don't want your system to ever run out of RAM+swap, but you usually would rather have enough RAM in the system so it doesn't need to swap.

Red hat recommends setting as follows for RHEL 5:

The reality is the amount of swap space a system needs is not really a function of the amount of RAM it has but rather the memory workload that is running on that system. A Red Hat Enterprise Linux 5 system will run just fine with no swap space at all as long as the sum of anonymous memory and system V shared memory is less than about 3/4 the amount of RAM. In this case the system will simply lock the anonymous and system V shared memory into RAM and use the remaining RAM for caching file system data so when memory is exhausted the kernel only reclaims pagecache memory.

Considering that 1) At installation time when configuring the swap space there is no easy way to predetermine the memory a workload will require, and 2) The more RAM a system has the less swap space it typically needs, a better swap space

Conclusion

If Linux kernel is going to use more than 2GiB swap space at a time, all users will feel the heat. Either, you get more RAM (recommend) and move to faster storage to improve disk I/O. There are no rules, each setup and configuration is unique. Adjust values as per your requirements. Select amount of swap that is right for you.

share|improve this answer
    
Please describe the link. –  N.N. Sep 19 '11 at 9:18
    
I just added excerpts from the source link that the answerer provided. @A T: Next time, please add atleast an excerpt from the source your are referring to or describe it. –  nitstorm Sep 19 '11 at 9:42
    
you know, there is no such paragraph in the linked OpenBSD FAQ... –  pqnet Aug 6 at 14:38

Normally you don't want (and shouldn't) use the swap that much, so yea, more than 8 gb seems like a lot. I have 8 gb of RAM on my desktop and a 8 gb swap, I don't think I ever used more than 1 gb of swap. The 2x rules makes sense for low amount of RAM but it gets a little crazy with ~6+ gb of RAM.

Of course it depends on what you're doing with your computer...

share|improve this answer

The only hard rule for swap space I know of is 1x RAM to Hibernate. The System Monitor or CLI free command will tell you how much swap space you're using with your particular hardware configuration and usage patterns. With 2GB of RAM my system rarely uses any swap space at all and never more than .4GB that I've seen.

share|improve this answer

Swap isn't something you want to use. It's something you want to have as a last resort because swap isn't fast, it's dead-slow. And if you are using like 1 GB of swap then your system will be really slow to respond.

The whole point of SWAP memory is to not have a system crash when you run out of available RAM. It's not something you can use as extra memory or something you really want to use, unless you really really have to.

So for size, I would say 5 GB but if you are really doing heavy stuff that uses a lot of RAM then you could go up to 8 GB. But really if you start using more than 1 GB of swap, start killing process's. so you DON'T have a crash.

share|improve this answer

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