[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: swap size

On  2 Sep, Max wrote:
> I'm about ready to setup a machine with 512 MB of RAM and I'm
> wondering how much swap space I should allocate.  I've read about the
> 2x rule, but 1 GB of swap seems somewhat excessive.  I've also been
> told that Linux will not use more than 128 MB of swap.  So, how much
> should I allocate?  Can I change it later without having to reinstall
> everything?  The machine is a dual-processor workstation that will be
> used by 4-8 people concurrently for number crunching and all sorts of
> simulations.
> Also, is it possible to put /tmp within swap?  Is that the default?
> Thanks,
>     Max

1GB isn't excessive if you're going to use it all.  A better rule is to
try to figure out what you will need*, and make sure that real + swap is
at least as large as what you need. Of course, it really does help if
real > average need and you only need to hit swap on rare occasions.  If
it turns out that you only need 480MB, max., then you probably don't
need any swap at all.  OTOH, if you are running something really huge,
then you might need 2GB swap, although that might turn out to be simply
too large for your system.  I think there is some benefit to having some
swap available, but I'm not enough of a kernel guru to know exactly why.
I did have a situation recently where I didn't have any swap, and I ran
out of RAM, and the system shut down sshd, breaking my connection.
Dunno why.  

* - don't forget the kernel, all the daemons, etc.etc.etc.  

At any rate, so long as you have disk space available, you can change
the amount of swap by running "mkswap" and "swapon"  with suitable
partitions, and you can do this on the fly.  You can even do this with
swap files in the regular filesystem, but I understand this isn't
recommended, for performance reasons and security reasons.  I haven't
done this, so I don't know how, but I'm sure it's in a HOWTO or a man
page someplace.  Worst case, you could add another hard drive and use
it for swap space if it turns out you need more.

The "correct" way to set up swap involves separate partitions, with a
different partition type and a separate format; /tmp needs to be part
of the regular filesystem, mounted in the usual manner, so I doubt you
can share space between /tmp and the swap space.

Stephen Ryan                   Debian GNU/Linux
Mathematics graduate student, Dartmouth College

Reply to: