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?
The text below was obtained from the nixCraft page Linux: Should You Use Twice the Amount of Ram as Swap Space?. (Please follow the link and read the source for more information)
Note that nixCraft page cites text purportedly coming from the OpenBSD FAQ, but there is no matching text in the current document; this may however be something that used to be in there in 2006 (so the 2 x RAM rule was already obsolete more than 10 years ago):
More from the nixCraft page:
And so the nixCraft page concludes:
Furthermore, this Red Hat article: Do we really need swap on modern systems? (2017) says:
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.
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.
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...