Re: Static Swap

Mike A. Harris (mharris@ican.net)
Mon, 19 Apr 1999 12:50:14 -0400 (EDT)


On Tue, 13 Apr 1999, Riley Williams wrote:

> >> I wanted to know wether linux can instead of having a static
> >> size swap have a dynamic size swap . That is if there is disk
> >> space available that is there is no valid data , that could be
> >> used for swap .
>
> >> Static swap also has a problem that when I increase my ram the
> >> swap also has to be increased for faster performance...
>
>There's a common misconception that the swap space one needs is
>exactly proportional to the amount of RAM one has, and this looks like
>a classic example of that...
>
>Can I state FROM EXPERIENCE that the so-called rule that swap space
>should be 1.5 times RAM size is BOGUS!!! Some systems need much more,
>others run happily on much less...
>
>My experience has been that the following apply...
>
> 1. All systems should have at least 4M of swap space, as Linux is (or
> at least appears to be) less stable otherwise.

I haven't ran all of the 2.2.x kernels, but I've ran practically
every 2.0.x kernel, and many of those were with ample RAM and
*NO* swap, with no instabilities.

> 2. Where a system has multiple hard drives, Linux appears to be more
> stable with a swap area on each drive than having some drives with
> no swap area on them.

Why? I've never encountered this.

> 3. The sum of RAM and swap space should be at least 32M on a system
> that is not running X, and at least 64M on a system that is
> running X.

I have a 486 set up as a simple firewall gateway with 8Mb RAM,
and no swap. Runs and runs and runs. Never had it crash.

> 4. Too much swap space is not a problem, but too little swap space
> really hurts.

Yes, if you run apps that use more VM than you have configured.

> 5. If the system in question regularly runs with more than 67% of its
> swap space used, more swap space should be allocated.
>
>Personally, I just allocate one 124M swap partition on each drive
>installed, always as a primary partition, and leave it at that. I've
>never had problems as a result of that policy, and with modern 2G+
>drives, the loss of 124M of data area per drive isn't even noticed.

Agreed. For a modern system with lots of disk space, a 124M
partition per drive is an EXCELLENT idea indeed. I chuck them in
extended partitions though.

> > If you need more swap space you can always swap to a file
> > instead of a partition. The priority can be set so that it uses
> > the swap partition first, then the swap file(s) for better
> > performance.
>
>I've never needed to do that, but can understand its use.

I've done it a few times when my system slowed down and I checked
free VM and found it steadily decreasing. I have a small script
that I wrote, called "aswap" which functions more or less as "Oh
shit, my system is running out of VM FAST! Make new swap space
as fast as possible on the drive that has the most free space!"

It searches ext2 drives first, followed by vfat, and finally
msdos drives. Whichever has the most space gets the temp
swapfile. Works great on the occasions I need it which are rare,
and usually due to a Netscape or KDE memleak.

> > IMHO, if you have unused space (non-partitioned) left on your
> > hard disk, it is just being wasted.
>
>True, but irrelevant - whether the space is unused because it hasn't
>been partitioned, or unused because no use is being made of the
>partition, it's still being wasted at that time.

Unless it's being used to collect 0's. ;o)

Take care, TTYL

--
Mike A. Harris                   Linux advocate      GNU advocate
Computer Consultant                          Open Source advocate  

The DVORAK keyboard layout RULES! I memorized it in 45 minutes and I don't think I'm ever going back to QWERTY!

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/