On Tue, 2010-06-22 at 00:27 +0200, Alex Schuster wrote:
> Walter Dnes writes:
> 
> >   I just got a brand new custom-built 8 gig machine.  There's an outfit
> > in north Toronto that has MSI motherboards with PS/2 ports, so I can
> > keep my genuine IBM PS/2 clickety-clack-keyboard; wooooohooooo.  And the
> > integrated Intel graphics chip has *BOTH VGA AND DIGITAL OUTPUTS*!
> 
> Hooray!
> 
> >   Anyhow, I have 8 gigs of ram on the sytem (will obviously be 64-bit
> > Gentoo) and I want to know how much swap I need.  The general rule of
> > thumb is twice the ram.  In this case, it would be 16 gigs.  I think
> > that it may not need swap when up, unless I do some heavy duty stuff.
> 
> I think this rule does not scale with todays amounts of system ram. If
> your system would need a similar amount of swap, swapping such a lot
> would make things really really slow. You could probably live without
> any swap, except for the purpose of hibernating to disk.
> 
> > My main concern about a swap partition is how much I need for
> > hibernate-to-disk to work.  Is there a rule about this, or should I
> > simply allocate 16 gigs out of my terabyte drive, and play it safe?
> 
> The amount of swap needed is the amount RAM actually being used on your
> system, compressed. Add the values of the 'used' fields of Mem and Swap
> in your free -m output, divide by two, and that should be somewhere near
> the amount you need. Maybe even less if tuxonice frees caches and
> buffers. 4GB should be more than enough, I'd think.
> 
> But hibernation also works with swap files, so there is no need to set
> the exact size already. And I suggest the usage of LVM, this way you can
> freely and very easily change the swap size as you like. I never install
> Linux without LVM these days, this flexibility makes things so much
> easier, and I do not have to care much about partition sizes.
> 
>       Wonko
> 

google has lots on this - this is one with a few ideas.
http://www.cyberciti.biz/tips/linux-swap-space.html

Generally hibernate (I use TuxOnIce with compression) uses around half
the occupied ram size - but you cant guarantee it, and if swap itself is
heavily loaded it gets critical.

In my case the most swap Ive ever used is 34Gb of a 145Gb swap partition
(5G ram, number crunching :) but graphics editing will sometimes require
up to 6gb swap in addition to ram.  Keep in mind that the maximum swap
available varies depending on physical architecture (I think!, cant find
the original reference now, but its recapped here:
http://ubuntuforums.org/showthread.php?t=606837) My experience is you
can create as much swap as you want - but the cpu will only use as much
as its capable of - wastage!  Note that i386 can only address 2Gb swap
in one partition, but you can have up to 32 swap partitions.

So its a 'how long is a piece of string' type question.

My 'algorithm' is something like:
1. swap is bad, get as much ram as possible

2. use a swap of 2xram 'just in case' that ram is not enough - better
that than a crash or oom event - disk space is cheap!  Added benefit is
almost always enough space for hibernate.

3. use multiple swap partitions with each one on a different physical
disk mounted with equal priority to allow striping for performance
benefits.  The more disks, the more swap partitions!  Create them at the
start of the disk as thats apparently the fastest place to put them -
http://lissot.net/partition/partition-04.html

3. if swap/hibernate space looks like being a problem, hibernate to a
file instead (see tuxonice, not sure if the flakey in-kernal hibernate
works with a file)

4. on systems expected to occasionally need extra swap keep a swapfile
around for instant use, or a script to create one on the fly

5. Tune the kernel swappable parameter to either force most everything
to swap to keep ram free or the other way to make it less likely to swap
if thats whats needed.  The current parameter is a compromise that works
in most cases, but there are uses that benefit one way or the other.

Lastly, to reiterate, disk space is cheap and putting aside 16Gb for
swap is a small price to pay for stability - you may only need it
occasionally, but then you will REALLY need it!

Have fun!

BillK




Reply via email to