Swap (was Re: [Techtalk] /usr Partition)

Travis Casey efindel at earthlink.net
Sun Jan 22 02:30:54 EST 2006


On Jan 20, 2006, at 4:38 PM, Kathryn Andersen wrote:
> On Thu, Jan 19, 2006 at 11:06:00PM -0500, Travis Casey wrote:

>> If you want to be able to analyze the results of system memory in the
>> event of a crash and full core dump, swap should be at least as big
>> as system memory.  If you don't care, then the only thing you need
>> swap for is if everything you're running won't fit into memory at  
>> once.
>
> This is interesting, because when I was first starting with Linux  
> about
> '95 or so (golly, that's about ten years!) I was told that swap should
> be 2 1/2 times the size of memory.

That's an old rule of thumb, from the days when Unix systems reserved  
swap for everything in memory as memory was allocated -- which meant  
that the system's virtual memory size was the size of the swap space,  
period, rather than the size of (memory + swap), as it is in most  
modern implementations.

Linux *never* used the older method -- but people used to the old  
rule of thumb that "swap should be at least twice the size of memory"  
from other Unixes carried it with them.

Note that that's also from back when most systems had maybe 16 or 32  
MB of memory, if you were lucky, and memory cost upwards of $10/MB.   
These days, with memory costing more like 10 cents/MB, it usually  
makes a lot more sense to just buy more memory if you're running  
low.  Personally, on workstation-type boxes, I tend to set up a  
fairly small swap area (maybe half the size of memory) and run some a  
monitor in my taskbar that shows memory and swap usage.  If I start  
to use a lot of swap -- which is very, very rare -- I'm right there  
and can do something about it.  I'm more conservative with swap on  
servers, though, since I'm not there when it's in use.

>> The modern rule of thumb is to have it equal to the size of memory if
>> you're feeling a little paranoid.
>
> What about if you want to use software suspend?  I gather that this
> suspends your system to your swap space, which means it needs to be at
> least the size of memory, and possibly more -- because what if you  
> were
> suspending and the swap space was *already* being used?  This, I do  
> not
> understand how it works.

The standard Linux software suspend -- CONFIG_SOFTWARE_SUSPEND --  
does not suspend to swap, and doesn't even have an option to do so.   
It uses a separate partition.

Suspend2 -- CONFIG_SUSPEND2 -- can use a separate partition, swap, or  
a "suspend file" on a normal filesystem.  If you choose to use swap,  
then you should make your swap area have enough "extra space" (above  
and beyond what you really need) to hold a copy of system memory.   
Note, though, that Suspend2 *can* work with less -- it can be  
configured to compress the suspend image, and if there's not enough  
space for the image, the kernel will attempt to free disk caches  
until it will fit.  If that isn't possible, it will gracefully give  
up, and not suspend the system.

--
Travis S. Casey           efindel at earthlink.net
I am an evil kitten!  Mew-ha-ha!




More information about the Techtalk mailing list