Poster of Linux kernelThe best gift for a Linux geek
swapd

swapd

Section: Maintenance Commands (8) Updated: May 21, 2000
Local index Up
 

NAME

swapd - dynamic swapping manager  

SYNOPSIS

swapd [-h] [--help] [--copyright] [--config file] [--maxswaps n] [--memlimit kb] [--mkswap path] [--pause msec] [--pidfile file] [--swapdir dir] [--swapsize kb] [--timeout sec]  

DESCRIPTION

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.  

OPTIONS

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 swap file.
--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 + swap).
 

CONFIGURATION

This is an example configuration file:

# swapd.conf - config file for swapd
#
# Copyright 2000 Neven Lovric <nlovric@jagor.srce.hr>
#

# 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
memlimit 16384

# 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
pause 1000

# Swap file size in kilobytes.
# >= 64, 4096 recommended
swapsize 4096

# 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
maxswaps 8

# 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
timeout 60

# Swap directory where all the swap files are kept.
swapdir /swap

# PID file (where the currently running swapd stores it's PID so a new swapd
# can find it)
pidfile /var/run/swapd.pid

# Full path to mkswap.
mkswap /sbin/mkswap
 

PERFORMANCE

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.  

FILES

/etc/swapd.conf
/var/run/swapd.pid
/etc/init.d/swapd
SWAPDIR/linux*.swp
 

BUGS

Might fail if swapping over NFS  

SEE ALSO

mkswap(8), swapon(8), swapoff(8), free(8)  

MAINTAINER

Aigars Mahinovs <aigarius@debian.org>  

AUTHOR

Neven Lovric <nlovric@linux.hr>

The latest upstream version is available via anonymous ftp:

ftp://ftp.linux.hr/pub/swapd


 

Index

NAME
SYNOPSIS
DESCRIPTION
OPTIONS
CONFIGURATION
PERFORMANCE
FILES
BUGS
SEE ALSO
MAINTAINER
AUTHOR

This document was created by man2html, using the manual pages.
Time: 22:02:28 GMT, April 16, 2011