NAME¶
swapspace - dynamically manage swap space
SYNOPSIS¶
swapspace [
options]
DESCRIPTION¶
Monitor memory and swap usage and allocate or deallocate swap space as needed.
This program aims to reduce or do away with the need for swapfiles.
swapspace can be built in two configurations: the full-featured one
(which is now the default) or the unconfigurable version. The latter only
accepts a few options, disabling all features that are probably only relevant
to developers. At some point in the feature, when enough confidence exists
that the various configuration parameters are either good enough for everyone
or have been made unnecessary, the unconfigurable build may become the
default.
The following options are accepted in the unconfigurable version. All of these
have more extensive equivalents in the full-featured version.
- -d
- Quietly ignored; always enabled in unconfigurable
version.
- -e
- Attempt to free up all allocated swap files. Returns 0 if
all files were successfully erased, or 1 otherwise.
- -h
- Display usage information and exit.
- -p
- Write process identifier to /var/lib/swapspace.pid
when starting (and delete it when shutting down). The file's name and
location cannot be changed in the unconfigurable version.
- -q
- Quietly ignored; always enabled in unconfigurable
version.
- -v
- Quietly ignored; always enabled in unconfigurable
version.
- -V
- Print program version information and exit.
In most cases, these should be the only options of any interest for normal use
of the program. All files are kept in their default locations, which were
chosen in accordance with the Linux Filesystem Hierarchy Standard, and
algorithmic parameters are left at defaults that have been tested to work well
for a wide range of uses.
The full-featured configuration accepts more options, as listed below. The
long-format options may also be specified, without the leading "--",
in a configuration file. By default,
/etc/swapspace.conf is read on
startup.
- -a duration,
--cooldown=duration
- If disk space runs out when allocating a swapfile, wait for
duration iterations (of roughly one second each) before considering
allocating one again; or if space doesn't run out, wait for
duration iterations before considering deallocating uneeded
swapfiles. This stabilizes the daemon's behaviour in the face of varying
memory requirements.
- -B p,
--buffer_elasticity=p
- Consider p% of system-allocated I/O buffers to be
available for other use.
- -c file, --configfile=file
- Read file instead of the default configuration
file.
- -C p, --cache_elasticity=p
- Consider p% of filesystem cache to be available for
other use.
- -d, --daemon
- Run quietly in the background. This is the normal way to
run the program.
- -e, --erase
- Attempt to free up all allocated swap files. Returns 0 if
all files were successfully erased, or 1 otherwise.
- -f p, --freetarget=p
- Aim to have p% of combined memory and swap space
free.
- -h, --help
- Display usage information and exit.
- -l p, --lower_freelimit=p
- Try to keep at least p% of combined memory and swap
space free; if less than p percent is available, attempt to
allocate more swap space.
- -M size,
--max_swapsize=size
- Never let swapfiles become larger than size bytes.
You don't normally need to set this; the daemon will learn when its swap
files get too big and adapt automatically.
- -m size,
--min_swapsize=size
- Never bother to allocate any swapfiles smaller than
size bytes. There should be no need to change this variable except
for testing.
- -p [file],
--pidfile[=file]
- Write process identifier to file when starting (and
delete file when shutting down); defaults to
/var/lib/swapspace.pid.
- -P, --paranoid
- Overwrite retired swapfiles before they are deleted, so an
attacker who obtains access to the disk without going through the system's
access control checks (e.g. by unplugging the computer and then rebooting
from a CD) cannot retrieve the swapped data. There is no guarantee that
this will work, and it will not thwart advanced forensic analysis using
custom-built hardware; but it may reduce the chances of an attacker with
physical access to the system obtaining passwords, credit card numbers
etc. The program will attempt to free up all allocated swapfiles on
termination and return a success code for this cleanup, as if the
--erase had been specified.
- Caution
- The --paranoid option will slow down swap file
management considerably. In particular, stopping the daemon will cause it
to try and deallocate (and wipe) all swapfiles it has created, and they
will not be available for swapping immediately after reboot.
- -q, --quiet
- Suppress informational output.
- -s dir, --swappath=dir
- Create swapfiles in directory dir instead of default
location /var/lib/swapspace. This location must be accessible to
root only; allowing anyone else to write to this directory or even
read swapped data would be a serious security breach.
- -u p, --upper_freelimit=p
- Avoid having more than p% of combined memory and
swap space free; if this percentage is exceeded, try to deallocate swap
space.
- -v, --verbose
- Log debug information to system log and/or standard output,
as appropriate.
- -V, --version
- Print program version information and exit.
Numbers may be suffixed with
k,
m,
g or
t to
indicate kilobytes, megabytes, gigabytes or terabytes respectively:
1k
means 1024 bytes,
1m means 1024 kilobytes,
4g means 4096
megabytes and so on.
Timings are measured in
iterations, which should typically last about one
second each. No pretense of accurate timing is made; this is not the kind of
program you would run on a hard-realtime system.
Any messages are sent to the system daemon log; it is also printed to the
standard output/error streams (as appropriate based on the urgency of each
individual message) if available.
SIGNALS¶
State information can be logged by sending the program the
SIGUSR1 signal
(user-defined signal 1). Not all of this information will always be current;
most of the information internal to
swapspace is only updated when
needed.
Sending the
SIGUSR2 signal will make the program free all swapfiles that
are not currently needed, and abstain from allocating any more for the
timespan of one cooldown period. The program will behave as if it just tried
to create a swapfile but ran out of disk space.
FILES¶
/etc/init.d/swapspace /etc/swapspace.conf /usr/sbin/swapspace
/var/lib/swapspace/
AUTHOR¶
Written by Jeroen T. Vermeulen
BUGS¶
Please report any bugs you may find on the project website at:
http://thaiopensource.org/development/swapspace/
COPYRIGHT¶
Copyright © 2005 Software Industry Promotion Agency (SIPA), Thailand
This is free software; see the source for copying conditions. There is no
warranty whatsoever. Use entirely at your own risk.
SEE ALSO¶
kill(1),
mkswap(8),
signal(7),
swapon(2),
swapoff(2),
swapon(8),
swapoff(8)