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

Re: Ideal Swap Partition Size

Paulo Cavalcanti wrote:
On Sat, Jan 17, 2009 at 9:52 AM, Rahul Tidke <rahul excelize com> wrote:

 I am configuring a server with 3 GB of RAM; how much swap partition size
should I allocate. I think allocating twice of RAM will be waste of HDD
space. What is the standard.

The double rule was created when computers had very little ram (< 512MB).

If you intend to hibernate, then you need at least the same size of the ram.
Otherwise, I think 1GB is good enough.  But you can always use a file as a

Reserving a swap area and its size is rather dependent on what the
machine is doing.  We have database servers that, on occasion, get
hammered and revert to using swap for a brief time.  We use a 2X swap
size and we've come close to using it all, so it's still valid.  You
will have to watch it---as soon as you start really whacking swap,
system performance is going to start suffering quite badly.

Note that a Linux swap _partition_ is limited to 2GB.  You are permitted
up to eight swap areas in the /etc/fstab (giving you a maximum of 16GB
swap in _partitions_).

Now, if you decide to use _file-based_ swap areas you can make each
swap file as large as you wish.  The files have to be contiguous and
pre-allocated before you initialize them and use them, e.g.

	# dd if=/dev/zero of=/path/to/swap/file bs=1M, count=4096

would create a 4GB file appropriate for swap usage.  Prep it for swap
usage by:

	# mkswap /path/to/swap/file

And use

	/path/to/swap/file	swap	swap	defaults 	0 0

in /etc/fstab to have it used at boot.  To use it immediately:

	# swapon /path/to/swap/file

Note you're still limited to eight swap areas, but the 2GB limit per
area goes away.  Swap files aren't as fast as swap partitions, but
that's part of the penalty you pay for getting rid of the 2GB limit.
Your mileage may vary, batteries not included, etc. etc.
- Rick Stevens, Systems Engineer                      ricks nerd com -
- AIM/Skype: therps2        ICQ: 22643734            Yahoo: origrps2 -
-                                                                    -
-         The world is coming to an end ... SAVE YOUR FILES!!!       -

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