Optimal Swap partition size


So here I am again with one more stupid query :wink:

I had earlier always installed Linux distros on my desktop and never bothered about swap size. However, laptops being little sensitive (compared to desktop) I am taking extra caution and seeking expert’s advice even on these lil things.

On a Core2Duo 2.2GHz Laptop, how much should be the optimal swap partition size?
Is the old rule of thumb: swap=(2XRAM) still valid?

I’ve 2GB RAM as of now and I’ll probably upgrade it to 4GB next year. So with multiple distros (Vista+few Linux) what should be the optimal swap size for my laptop.

P.S: I searched the forums but couldn’t find the ans.

And if you had, you would probably have found conflicting answers. You need some swap but, as people have pointed out in other posts, the more RAM you have the less likely Linux is to use swap and, unless you are using memory very intensively, you may find that with 4Gb, it never uses whatever swap you have set aside.

I have 1Gb RAM and 2Gb swap installed by openSUSE and at the moment I am using no swap and less than ½Gb (plus ¼Gb caches).

Apart from the conflicting answers, I also read:
To have “suspend to disk” option that is similar to Hibernate, I need to have swap=(2xRAM).
This caused the perplexed situation.

YMMV, but on all of my systems I have at least 2GB of RAM. I did some mild experimentation in the past, and found that with that amount of RAM, my system never used swap unless the system crashed (which only happened once b/c I was an idiot :wink: ).

So, if your system has 2+ GB of ram, I would allocate 1GB of swap space and let it be.

Slightly off topic, but if you’re coming from Windows land, and are expecting recommendations similar to the mountain of FUD that exists in regards to the Windows page file, you won’t find any. The linux swap partition is simpler than the Windows page file, and so the recommendations are more straight-forward.

Back on topic now, and remember, ymmv. :slight_smile:

2xRAM is the Windows thinking, linux’s kernel is very good at managing the memory and you certainly don’t need twice as much swap as you got RAM. Having 2GB of memory i wouldn’t even personally create swap. At most you’d need the same amount of swap as RAM.