Linked by David Adams on Thu 20th Nov 2008 04:19 UTC
General Unix Linux and other Unix-like operating systems use the term "swap" to describe both the act of moving memory pages between RAM and disk. It is common to use a whole partition of a hard disk for swapping. However, with the 2.6 Linux kernel, swap files are just as fast as swap partitions. Now, many admins (both Windows and Linux/UNIX) follow an old rule of thumb that your swap partition should be twice the size of your main system RAM. Let us say I’ve 32GB RAM, should I set swap space to 64 GB? Is 64 GB of swap space really required? How big should your Linux / UNIX swap space be?
Thread beginning with comment 337846
To read all comments associated with this story, please click here.
Comment by Traumflug
by Traumflug on Thu 20th Nov 2008 10:08 UTC
Traumflug
Member since:
2008-05-22

Admittedly, I never could follow the reasoning for this 2x-RAM-rule.

About any piece of software out there requires some absolute amount of RAM and doesn't care wether this RAM is available physically or not. So multiplying the physical amount of RAM with any number is meaningless. What you really want is a rule of thumb for an absolute number.

Example: Running Ubuntu with some desktop stuff needs about 1.5 GB of RAM (worst case scenario), so make sure you have 2 GB of RAM available to be on the safe side. If you have 0.5 GB physical RAM, allocate 1.5 GB swap. If you have 1 GB physical RAM, 1 GB swap is sufficient.

Nowadays, with most desktop PCs having 2 GB physical RAM or more, it's actually questionable wether you need swap at all. If you install a 32-bit OS on a machine with 4 GB physical RAM you can safely ignore swap as the OS can't even address the extra. A common scenario these days, yet most Linux distros still insist on allocating a swap partition.

Reply Score: 3

RE: Comment by Traumflug
by Yagami on Thu 20th Nov 2008 10:32 in reply to "Comment by Traumflug"
Yagami Member since:
2006-07-15

yeah, this makes much more sense.

just target a memory size that your system needs and make the swap size with whats missing from your ram !

with the weird calculations that the article mentions, sometimes its "better" ( as in you have less swap ) with less ram !

i just target the 2GB size. As i already have 2 gb of ram there isnt any swap needed.

if you have 512MB, dont make a 1 gb swap , as your system will only have 1.5 GB memory capacity, but a 1.5 GB swap so it reaches the 2GB capacity. ( just in theory, since linux will hardly ever need that for normal desktop usage )

having said that, from the article i guess i better make a 3 gb swap so my laptop can suspend to ram. (anyways, whats 3 gb more or less in my hardrive ?!? ;) )

Reply Parent Score: 1

RE[2]: Comment by Traumflug
by computrius on Fri 21st Nov 2008 13:22 in reply to "RE: Comment by Traumflug"
computrius Member since:
2006-03-26

Does this mean that if I have 4 gig of ram someone is going to ship me a free 2gb hard drive?

Send it to my home address please ;)

Reply Parent Score: 2

RE: Comment by Traumflug
by Bill Shooter of Bul on Thu 20th Nov 2008 15:59 in reply to "Comment by Traumflug"
Bill Shooter of Bul Member since:
2006-07-14

If you install a 32-bit OS on a machine with 4 GB physical RAM you can safely ignore swap as the OS can't even address the extra. A common scenario these days, yet most Linux distros still insist on allocating a swap partition.


No, 32 bit linux can address more than 4 GB with Physical Address Extension (PAE) support ( which every processor has had since Pentium Pro) .

http://en.wikipedia.org/wiki/Physical_Address_Extension

Reply Parent Score: 2

RE: Comment by Traumflug
by looncraz on Thu 20th Nov 2008 22:30 in reply to "Comment by Traumflug"
looncraz Member since:
2005-07-24

Except each application can address 4 GB, technically. Though your way is less mathematically involved than my nice little formula :-)

--The loon

Reply Parent Score: 2