swapd - dynamic swapping manager
swapd [-h] [--help] [--copyright] [--config file] [--maxswaps n]
[--memlimit kb] [--mkswap path] [--pause msec] [--pidfile file]
[--swapdir dir] [--swapsize kb] [--timeout sec]
swapd is a dynamic swapping manager. It provides the system with as
much swap space (virtual memory) as is required at a particular time by
dynamicly creating swap files. This is more convinient than using fixed
swap files and/or partitions because they (a) are unused most of the
time and are just taking up disk space; and (b) provide a limited
amount of virtual memory.
All values given on the command line will override config file values.
-h, --help Displays the command line help.
--copyright Displays the copyright notice.
--config file Location of an alternate configuration file.
--maxswaps n Maximum number of swap files. No more than n swap files
will be used. The default is 8 (as many as the default
kernel will allow).
--memlimit kb Memory limit in kilobytes. When the total amount of
free memory gets below this number, swapd creates a new
--mkswap path Location of mkswap(8), usually /sbin/mkswap.
--pause msec Pause between memory checks in miliseconds (when the
total amount of free memory is above memlimit).
--pidfile file Location of the PID file, usually /var/run/swapd.pid.
--swapdir dir Swap directory where all the swap files are kept.
--swapsize kb Swap file size (>=64k).
--timeout sec Timeout. If the last created swap file is unused for
sec seconds, it will be removed. The last created
swapfile is considered unused when there are more than
memlimit + swapsize kb of free memory (physical +
This is an example configuration file:
# swapd.conf - config file for swapd
# Copyright 2000 Neven Lovric <firstname.lastname@example.org>
# Memory limit in kilobytes.
# When the total amount of free memory gets below this number, swapd creates
# a new swap file.
# 16384 or more recommended
# Pause between memory checks in miliseconds.
# When the total amount of free memory is above <memlimit>, swapd will pause
# for <pause> miliseconds before checking memory again.
# 1000 should be ok for most systems
# Swap file size in kilobytes.
# >= 64, 4096 recommended
# Maximum number of swap files.
# No more than <maxswaps> swap files will be used.
# 0 = unlimited (as many as the kernel will allow)
# 8 = how many a default kernel allows
# Timeout in seconds.
# If the last created swap file is unused for <sec> seconds, it will be
# removed. The last created swapfile is considered unused when there are
# more than <memlimit> + <swapsize> kb of free memory (physical + swap).
# 60 is nice
# Swap directory where all the swap files are kept.
# PID file (where the currently running swapd stores it’s PID so a new swapd
# can find it)
# Full path to mkswap.
The most important parameter which may drasticly effect performance is
the memory limit. If the memory limit is low, (1) there may not be
enough memory ready for a program to allocate at once or (2) swapd may
not be able to create new swap files before we run out of memory. If
your programs are running out of memory, it will primarily be due to a
low memory limit. If you really want to have a low memory limit, you
should decrease the swap size and pause.
The second important parameter is the swap size. If you choose to use
bigger swap files, you may experience slowdowns when swap files are
created. On the other hand, small swap files may lower performance when
there are many of them. The important thing is not to make them too big
to create before we run out of memory.
Another important parameter is the pause, which should be shorter on
faster systems. If it is too long, swapd may fail to detect rapid
memory changes and therefore fail to create new swap files when they
are needed. However, if you notice swapd is constantly using too much
CPU, increase the pause.
Might fail if swapping over NFS
mkswap(8), swapon(8), swapoff(8), free(8)
Aigars Mahinovs <email@example.com>
Neven Lovric <firstname.lastname@example.org>
The latest upstream version is available via anonymous ftp: