2003-12-20 14:22:25 +03:00
|
|
|
.\" $NetBSD: swapctl.8,v 1.27 2003/12/20 11:22:25 mrg Exp $
|
1997-06-12 17:14:11 +04:00
|
|
|
.\"
|
|
|
|
.\" Copyright (c) 1997 Matthew R. Green
|
|
|
|
.\" All rights reserved.
|
|
|
|
.\"
|
|
|
|
.\" Redistribution and use in source and binary forms, with or without
|
|
|
|
.\" modification, are permitted provided that the following conditions
|
|
|
|
.\" are met:
|
|
|
|
.\" 1. Redistributions of source code must retain the above copyright
|
|
|
|
.\" notice, this list of conditions and the following disclaimer.
|
|
|
|
.\" 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
.\" notice, this list of conditions and the following disclaimer in the
|
|
|
|
.\" documentation and/or other materials provided with the distribution.
|
1997-10-23 07:00:12 +04:00
|
|
|
.\" 3. The name of the author may not be used to endorse or promote products
|
1997-06-12 17:14:11 +04:00
|
|
|
.\" derived from this software without specific prior written permission.
|
|
|
|
.\"
|
|
|
|
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
|
|
|
.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
|
|
.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
|
|
.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
|
|
.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
|
|
|
.\" BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
|
|
.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
|
|
|
.\" AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
|
|
.\" OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
.\" SUCH DAMAGE.
|
|
|
|
.\"
|
2000-03-05 14:35:22 +03:00
|
|
|
.Dd March 5, 2000
|
1997-06-12 17:14:11 +04:00
|
|
|
.Dt SWAPCTL 8
|
2001-06-05 15:22:41 +04:00
|
|
|
.Os
|
1997-06-12 17:14:11 +04:00
|
|
|
.Sh NAME
|
1997-11-11 17:39:59 +03:00
|
|
|
.Nm swapctl ,
|
|
|
|
.Nm swapon
|
1997-06-12 17:14:11 +04:00
|
|
|
.Nd system swap management tool
|
|
|
|
.Sh SYNOPSIS
|
1997-09-15 15:21:59 +04:00
|
|
|
.Nm
|
1997-06-15 08:08:33 +04:00
|
|
|
.Fl A
|
1997-06-12 17:14:11 +04:00
|
|
|
.Op Fl p Ar priority
|
1997-06-26 03:18:10 +04:00
|
|
|
.Op Fl t Ar blk|noblk
|
2003-02-25 13:34:36 +03:00
|
|
|
.Nm
|
2000-03-05 14:35:22 +03:00
|
|
|
.Fl D Ar dumpdev
|
2003-02-25 13:34:36 +03:00
|
|
|
.Nm
|
2000-03-05 14:35:22 +03:00
|
|
|
.Fl U
|
|
|
|
.Op Fl t Ar blk|noblk
|
2003-02-25 13:34:36 +03:00
|
|
|
.Nm
|
1997-06-15 08:08:33 +04:00
|
|
|
.Fl a
|
1997-06-12 17:14:11 +04:00
|
|
|
.Op Fl p Ar priority
|
|
|
|
.Ar path
|
2003-02-25 13:34:36 +03:00
|
|
|
.Nm
|
1997-06-15 08:08:33 +04:00
|
|
|
.Fl c
|
|
|
|
.Fl p Ar priority
|
|
|
|
.Ar path
|
2003-02-25 13:34:36 +03:00
|
|
|
.Nm
|
1997-06-15 08:08:33 +04:00
|
|
|
.Fl d
|
|
|
|
.Ar path
|
2003-02-25 13:34:36 +03:00
|
|
|
.Nm
|
1997-06-15 08:08:33 +04:00
|
|
|
.Fl l | Fl s
|
1997-06-12 17:14:11 +04:00
|
|
|
.Op Fl k
|
2003-12-20 14:22:25 +03:00
|
|
|
.Op Fl h
|
2003-02-25 13:34:36 +03:00
|
|
|
.Nm
|
2000-11-17 14:43:41 +03:00
|
|
|
.Fl z
|
1997-06-12 17:14:11 +04:00
|
|
|
.Nm swapon
|
1997-06-15 08:08:33 +04:00
|
|
|
.Fl a | Ar path
|
1997-06-12 17:14:11 +04:00
|
|
|
.Sh DESCRIPTION
|
|
|
|
The
|
|
|
|
.Nm
|
1997-06-15 08:08:33 +04:00
|
|
|
program adds, removes,
|
1997-06-12 17:14:11 +04:00
|
|
|
lists and prioritizes swap devices and files for the system.
|
|
|
|
The
|
|
|
|
.Nm swapon
|
|
|
|
program acts the same as the
|
|
|
|
.Nm
|
|
|
|
program, as if called with the
|
|
|
|
.Fl a
|
|
|
|
option, except if
|
|
|
|
.Nm swapon
|
|
|
|
itself is called with
|
|
|
|
.Fl a
|
|
|
|
in which case,
|
|
|
|
.Nm swapon
|
2001-10-02 03:15:59 +04:00
|
|
|
acts as
|
1997-06-12 17:14:11 +04:00
|
|
|
.Nm
|
|
|
|
with the
|
|
|
|
.Fl A
|
|
|
|
option.
|
2001-11-16 14:26:53 +03:00
|
|
|
.Pp
|
1997-06-12 17:14:11 +04:00
|
|
|
The following options are available:
|
|
|
|
.Bl -tag -width 123456
|
|
|
|
.It Fl A
|
1998-01-26 09:58:01 +03:00
|
|
|
This option causes
|
1997-06-12 17:14:11 +04:00
|
|
|
.Nm
|
|
|
|
to read the
|
|
|
|
.Pa /etc/fstab
|
2001-10-02 03:15:59 +04:00
|
|
|
file for devices and files with a
|
1999-02-23 20:00:53 +03:00
|
|
|
.Dq sw
|
|
|
|
and
|
|
|
|
.Dq dp
|
|
|
|
type, and adds all these entries
|
|
|
|
as swap devices, or for a dump device in the case of a
|
|
|
|
.Dq dp
|
2002-10-01 18:53:58 +04:00
|
|
|
type.
|
|
|
|
If no swap devices are configured,
|
1998-02-10 06:14:32 +03:00
|
|
|
.Nm
|
|
|
|
will exit with an error code.
|
1999-02-23 20:00:53 +03:00
|
|
|
.It Fl D
|
|
|
|
The
|
|
|
|
.Fl D
|
|
|
|
option requires that a
|
|
|
|
.Ar dumpdev
|
2002-10-01 18:53:58 +04:00
|
|
|
also be in the argument list.
|
|
|
|
The kernel dump device is set to
|
1999-02-23 20:00:53 +03:00
|
|
|
.Ar dumpdev .
|
|
|
|
This changed is made via the
|
|
|
|
.Xr swapctl 2
|
2002-10-01 18:53:58 +04:00
|
|
|
system call.
|
|
|
|
The dump device is used when the system crashes
|
1999-02-23 20:00:53 +03:00
|
|
|
to write a current snapshot of real memory, to be saved later with
|
|
|
|
.Xr savecore 8
|
|
|
|
at system reboot, and analyzed to determine the problem.
|
2000-03-05 14:35:22 +03:00
|
|
|
.It Fl U
|
|
|
|
This option causes
|
|
|
|
.Nm
|
|
|
|
to read the
|
|
|
|
.Pa /etc/fstab
|
2001-10-02 03:15:59 +04:00
|
|
|
file for devices and files with a
|
2000-03-05 14:35:22 +03:00
|
|
|
.Dq sw
|
2002-10-01 18:53:58 +04:00
|
|
|
type, and remove all these entries as swap devices.
|
2000-03-05 14:35:22 +03:00
|
|
|
If no swap devices are unconfigured,
|
|
|
|
.Nm
|
|
|
|
will exit with an error code.
|
1997-06-12 17:14:11 +04:00
|
|
|
.It Fl a
|
|
|
|
The
|
|
|
|
.Fl a
|
|
|
|
option requires that a
|
|
|
|
.Ar path
|
2002-10-01 18:53:58 +04:00
|
|
|
also be in the argument list.
|
|
|
|
The
|
1997-06-12 17:14:11 +04:00
|
|
|
.Ar path
|
|
|
|
is added to the kernel's list of swap devices using the
|
|
|
|
.Xr swapctl 2
|
2002-10-01 18:53:58 +04:00
|
|
|
system call.
|
|
|
|
When using the
|
1997-06-12 17:14:11 +04:00
|
|
|
.Nm swapon
|
|
|
|
form of this command, the
|
|
|
|
.Fl a
|
|
|
|
option is treated the same as the
|
|
|
|
.Fl A
|
|
|
|
option, for backwards compatibility.
|
|
|
|
.It Fl c
|
|
|
|
The
|
|
|
|
.Fl c
|
|
|
|
option changes the priority of the listed swap device or file.
|
1997-06-15 08:08:33 +04:00
|
|
|
.It Fl d
|
|
|
|
The
|
|
|
|
.Fl d
|
|
|
|
option removes the listed
|
|
|
|
.Ar path
|
|
|
|
from the kernel's list of swap devices or files.
|
1997-06-12 17:14:11 +04:00
|
|
|
.It Fl l
|
|
|
|
The
|
|
|
|
.Fl l
|
|
|
|
option lists the current swap devices and files, and their usage statistics.
|
|
|
|
.It Fl s
|
|
|
|
The
|
|
|
|
.Fl s
|
|
|
|
option displays a single line summary of current swap statistics.
|
|
|
|
.It Fl p
|
|
|
|
The
|
|
|
|
.Fl p
|
|
|
|
option sets the priority of swap devices or files to the
|
|
|
|
.Ar priority
|
2002-10-01 18:53:58 +04:00
|
|
|
argument.
|
|
|
|
This works with the
|
1997-06-12 17:14:11 +04:00
|
|
|
.\" .Fl d ,
|
|
|
|
.Fl a ,
|
2002-10-01 18:53:58 +04:00
|
|
|
.Fl c ,
|
1997-06-12 17:14:11 +04:00
|
|
|
and
|
|
|
|
.Fl l
|
|
|
|
options.
|
|
|
|
.It Fl k
|
|
|
|
The
|
|
|
|
.Fl k
|
|
|
|
option uses 1024 byte blocks instead of the default 512 byte.
|
2003-12-20 14:22:25 +03:00
|
|
|
.It Fl h
|
|
|
|
The
|
|
|
|
.Fl h
|
|
|
|
option uses
|
|
|
|
.Xr humanize_number 3
|
|
|
|
to display the sizes.
|
1997-06-26 04:51:07 +04:00
|
|
|
.It Fl t
|
|
|
|
This flag modifies the function of the
|
|
|
|
.Fl A
|
2000-03-05 14:35:22 +03:00
|
|
|
and
|
|
|
|
.Fl U
|
|
|
|
options.
|
1997-06-26 04:51:07 +04:00
|
|
|
The
|
|
|
|
.Fl t
|
2002-10-01 18:53:58 +04:00
|
|
|
option allows the type of device to add to be specified.
|
|
|
|
An argument of
|
1997-06-26 04:51:07 +04:00
|
|
|
.Ar blk
|
|
|
|
causes all block devices in
|
|
|
|
.Pa /etc/fstab
|
2002-10-01 18:53:58 +04:00
|
|
|
to be added.
|
|
|
|
An argument of
|
1997-06-26 04:51:07 +04:00
|
|
|
.Ar noblk
|
|
|
|
causes all non-block devices in
|
|
|
|
.Pa /etc/fstab
|
2002-10-01 18:53:58 +04:00
|
|
|
to be added.
|
|
|
|
This option is useful in early system startup, where swapping
|
1997-06-26 04:51:07 +04:00
|
|
|
may be needed before all file systems are available, such as during
|
|
|
|
disk checks of large file systems.
|
2000-11-17 14:43:41 +03:00
|
|
|
.It Fl z
|
|
|
|
The
|
|
|
|
.Fl z
|
|
|
|
option displays the current dump device.
|
1997-06-12 17:14:11 +04:00
|
|
|
.El
|
2001-04-11 18:10:17 +04:00
|
|
|
.Sh SWAP PRIORITY
|
|
|
|
The
|
|
|
|
.Nx
|
|
|
|
swap system allows different swap devices and files to be assigned different
|
|
|
|
priorities, to allow the faster resources to be used first.
|
|
|
|
Swap devices at the same priority are used in a round-robin fashion until
|
|
|
|
there is no more space available at this priority, when the next priority
|
|
|
|
level will be used.
|
2002-10-01 18:53:58 +04:00
|
|
|
The default priority is 0, the highest.
|
|
|
|
This value can be any valid integer,
|
2001-04-11 18:10:17 +04:00
|
|
|
with higher values receiving less priority.
|
1997-06-15 07:52:02 +04:00
|
|
|
.Sh SWAP OPTIONS
|
|
|
|
When parsing the
|
|
|
|
.Pa /etc/fstab
|
1998-01-26 09:58:01 +03:00
|
|
|
file for swap devices, the following options are recognized:
|
1997-06-15 07:52:02 +04:00
|
|
|
.Pp
|
|
|
|
.Bl -tag -width nfsmntpt=/path -compact
|
|
|
|
.It priority=N
|
2001-04-11 18:10:17 +04:00
|
|
|
This option sets the priority of the specified swap device to N.
|
1997-06-15 07:52:02 +04:00
|
|
|
.It nfsmntpt=/path
|
2002-10-01 18:53:58 +04:00
|
|
|
This option is useful for swapping to NFS files.
|
|
|
|
It specifies the local mount point to mount an NFS filesystem.
|
2003-01-24 22:48:52 +03:00
|
|
|
The mount point must exist as a directory.
|
2002-10-01 18:53:58 +04:00
|
|
|
Typically, once this mount has succeeded, the file to be used for swapping
|
|
|
|
on will be available under this point mount.
|
|
|
|
For example:
|
2001-10-02 03:15:59 +04:00
|
|
|
.Bd -literal
|
1997-06-15 07:52:02 +04:00
|
|
|
server:/export/swap/client none swap sw,nfsmntpt=/swap
|
|
|
|
.Ed
|
|
|
|
.El
|
2001-11-16 14:26:53 +03:00
|
|
|
.Sh SEE ALSO
|
|
|
|
.Xr swapctl 2 ,
|
|
|
|
.Xr fstab 5 ,
|
|
|
|
.Xr mount_nfs 8
|
|
|
|
.Sh HISTORY
|
|
|
|
The
|
|
|
|
.Nm
|
|
|
|
program was first made available in
|
|
|
|
.Nx 1.3 .
|
|
|
|
The original
|
|
|
|
.Nm swapon
|
|
|
|
program, provided for backwards compatibility, appeared in
|
|
|
|
.Bx 4.0 .
|
|
|
|
.Sh AUTHORS
|
|
|
|
The
|
|
|
|
.Nm
|
2002-10-01 18:53:58 +04:00
|
|
|
program was written by
|
|
|
|
.An Matthew R. Green Aq mrg@eterna.com.au .
|
2001-11-16 14:26:53 +03:00
|
|
|
.Sh BUGS
|
1997-06-26 04:51:07 +04:00
|
|
|
If no swap information is specified in
|
|
|
|
.Pa /etc/fstab ,
|
|
|
|
the system startup scripts (see
|
|
|
|
.Xr rc 8 )
|
|
|
|
will configure no swap space and your machine will behave very badly
|
|
|
|
if (more likely when) it runs out of real memory.
|
|
|
|
.Pp
|
|
|
|
Local and remote swap files cannot be configured until after the file
|
2002-10-01 18:53:58 +04:00
|
|
|
systems they reside on are mounted read/write.
|
|
|
|
The system startup scripts need to
|
1997-06-26 04:51:07 +04:00
|
|
|
.Xr fsck 8
|
2002-10-01 18:53:58 +04:00
|
|
|
all local file systems before this can happen.
|
|
|
|
This process requires substantial amounts of memory on some systems.
|
|
|
|
If you configure no local block swap devices on a machine that has local
|
|
|
|
file systems to check and rely only on swap files, the machine will have
|
|
|
|
no swap space at all during system
|
1997-06-26 04:51:07 +04:00
|
|
|
.Xr fsck 8
|
|
|
|
and may run out of real memory, causing fsck to abnormally exit and
|
|
|
|
startup scripts to fail.
|