Why should we make SWAP partition twice as big as RAM ?
I am using linux for the past 5 years.Everytime i install it i made swap partition =2*RAM.Based on some recommendations as follows ..
For Desktop environments ..
If RAM is very less i.e.<=512MB
If RAM is >512MB but <=2GB
If RAM is >2GB
If RAM is huge
I did some googling and foundout that VM paging algorithms works well when the swap is as supposed.
One more interesting response is earlier systems allocate memory for a process first in SWAP and then load if needed so if swap=ram we can have virtual memory equal to ram which is of no use.So they made swap=2*ram .But now we don't follow that but earlier machanism is still followed.
Now my question is which one of these is correct or incorrect if correct why ?? if not what else ??
Please give me as much detail as you can ..
The old rule-of-thumb was just that, a simple way to gauge the approximate amount of swap the average system needed, back when RAM was a premium commodity. Now that even your average home system can have huge banks of memory the advice is mostly outdated and systems can get by on less. But then again they also have giant hard disks, so there's very little cost to having it anyway.
There are by now probably hundreds of previous threads discussing whether and how much swap is needed. Go check some of them out. You can start with the "similar threads" box at the bottom of this page.
I agree with David the H. Installers are for generic installs and tend to err on the side if safety. If you wish you can create a system that is based on both your hardware and software and OS choice.
Today's ram is so much faster, compared to any hard drive access one may be tempted to never use swap. It takes time to use swap and hold swap to the OS. Only your install would determine the correct use. In many cases it doesn't seem to hurt to use swap but you can also modify how swap is used.
Linux normally does not use swap at all. It only swaps out dirty pages that are not referenced anymore for any reasons. Use 'free' to see the actual swap usage, for example. But! Swap is still a part of virtual memory, and does need to be present in the system that is RAM-hungry. For example java apps, that allocated virtual memory for heap. Just run top and see that in most cases virtual memory allocated to a process exceeds physical RAM used by this process. So in the absence of swap, a new application might not be able to start due to not being able to reserve enough virtual memory even if there is enough RAM for it to run, or a system out-of-memory daemon will go kill some consumers of ram and this that can be pretty bad! See also description of vm.overcommit sysctl option which IIRc should be set to 2 for best results, provided that there is plenty of virtual memory.
to conserve disk space used by the swap partition, you could perhaps make for it a special LVM volume that is thin-provisioned, i.e. that takes less physical space on disk than it presents to the system. You'll only need to allocated some megabytes worth of disk space and the system will see whatever gigabytes of swap partition you like. Please excuse for not giving you full details, they tend to leave my head with little traces :), but do check out man page for lvcreate or may be some other man pages related to LVM. Do post back your findings :)
|All times are GMT -5. The time now is 09:13 PM.|