LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Virtualization and Cloud
User Name
Password
Linux - Virtualization and Cloud This forum is for the discussion of all topics relating to Linux Virtualization and Linux Cloud platforms. Xen, KVM, OpenVZ, VirtualBox, VMware, Linux-VServer and all other Linux Virtualization platforms are welcome. OpenStack, CloudStack, ownCloud, Cloud Foundry, Eucalyptus, Nimbus, OpenNebula and all other Linux Cloud platforms are welcome. Note that questions relating solely to non-Linux OS's should be asked in the General forum.

Notices


Reply
  Search this Thread
Old 01-25-2011, 05:10 AM   #1
dazzlinggopi
LQ Newbie
 
Registered: Jul 2010
Posts: 5

Rep: Reputation: 0
Question Why should we make SWAP partition twice as big as RAM ?


Hi guys,
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
swap ~1GB
If RAM is >512MB but <=2GB
swap=2*RAM.
If RAM is >2GB
swap=RAM.
If RAM is huge
swap=<3GB.

For Servers

Swap=0.5*RAM ..

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 ..

Last edited by dazzlinggopi; 01-25-2011 at 05:12 AM.
 
Old 01-25-2011, 05:55 AM   #2
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Arch + Xfce
Posts: 6,852

Rep: Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037
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.
 
Old 01-25-2011, 03:00 PM   #3
jefro
Moderator
 
Registered: Mar 2008
Posts: 21,982

Rep: Reputation: 3626Reputation: 3626Reputation: 3626Reputation: 3626Reputation: 3626Reputation: 3626Reputation: 3626Reputation: 3626Reputation: 3626Reputation: 3626Reputation: 3626
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.
 
Old 02-23-2011, 01:38 PM   #4
datamove
LQ Newbie
 
Registered: Feb 2011
Posts: 17

Rep: Reputation: 3
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
 
1 members found this post helpful.
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
A swap partition so be how big? skeetnah Slackware 19 09-25-2008 06:11 AM
2 GB of ram, do I need a swap partition? davesbedroom Linux - General 2 03-31-2005 11:43 AM
Can a swap or boot partition be too big? gadams33 Linux - Newbie 4 08-22-2004 05:48 PM
How big to make swap file? Mandrake92 Linux - Newbie 11 05-26-2004 03:19 PM
Swap Partition - RAM?? jt1020 Linux - General 7 04-30-2003 08:02 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Virtualization and Cloud

All times are GMT -5. The time now is 12:42 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration