2006-12-06 17:25:37 -06:00
|
|
|
.\" Copyright 1998 Andries E. Brouwer (aeb@cwi.nl)
|
|
|
|
.\"
|
2006-12-06 17:25:32 -06:00
|
|
|
.\" May be distributed under the GNU General Public License
|
2006-12-06 17:25:37 -06:00
|
|
|
.\" Rewritten for 2.1.117, aeb, 981010.
|
|
|
|
.\"
|
2009-03-13 08:31:31 -05:00
|
|
|
.TH MKSWAP 8 "13 March 2009" "Linux" "Linux Programmer's Manual"
|
2006-12-06 17:25:32 -06:00
|
|
|
.SH NAME
|
2006-12-06 17:25:33 -06:00
|
|
|
mkswap \- set up a Linux swap area
|
2006-12-06 17:25:32 -06:00
|
|
|
.SH SYNOPSIS
|
2009-07-22 04:29:04 -05:00
|
|
|
.B mkswap
|
|
|
|
.RB [ \-c ]
|
|
|
|
.RB [ \-f ]
|
|
|
|
.RB [ \-p
|
|
|
|
.IR PSZ ]
|
|
|
|
.RB [ \-L
|
|
|
|
.IR label ]
|
|
|
|
.RB [ \-U
|
|
|
|
.IR uuid ]
|
2009-10-29 10:29:56 -05:00
|
|
|
.I device
|
2009-07-22 04:29:04 -05:00
|
|
|
.RI [ size ]
|
2006-12-06 17:25:32 -06:00
|
|
|
.SH DESCRIPTION
|
|
|
|
.B mkswap
|
2006-12-06 17:25:33 -06:00
|
|
|
sets up a Linux swap area on a device or in a file.
|
2006-12-06 17:25:32 -06:00
|
|
|
|
|
|
|
The
|
|
|
|
.I device
|
2006-12-06 17:25:37 -06:00
|
|
|
argument will usually be a disk partition (something like
|
|
|
|
.IR /dev/sdb7 )
|
|
|
|
but can also be a file.
|
2010-06-20 07:39:59 -05:00
|
|
|
The Linux kernel does not look at partition IDs, but
|
2006-12-06 17:25:37 -06:00
|
|
|
many installation scripts will assume that partitions
|
|
|
|
of hex type 82 (LINUX_SWAP) are meant to be swap partitions.
|
2010-06-20 07:39:59 -05:00
|
|
|
(\fBWarning: Solaris also uses this type. Be careful not to kill
|
2009-03-13 08:31:31 -05:00
|
|
|
your Solaris partitions.\fP)
|
2006-12-06 17:25:32 -06:00
|
|
|
|
|
|
|
The
|
2006-12-06 17:25:37 -06:00
|
|
|
.I size
|
|
|
|
parameter is superfluous but retained for backwards compatibility.
|
|
|
|
(It specifies the desired size of the swap area in 1024-byte blocks.
|
2006-12-06 17:25:33 -06:00
|
|
|
.B mkswap
|
2006-12-06 17:25:39 -06:00
|
|
|
will use the entire partition or file if it is omitted.
|
2010-06-20 07:39:59 -05:00
|
|
|
Specifying it is unwise -- a typo may destroy your disk.)
|
2006-12-06 17:25:33 -06:00
|
|
|
|
2006-12-06 17:25:41 -06:00
|
|
|
The
|
|
|
|
.I PSZ
|
2010-06-20 07:39:59 -05:00
|
|
|
parameter specifies the page size to use. It is almost always
|
2006-12-06 17:25:41 -06:00
|
|
|
unnecessary (even unwise) to specify it, but certain old libc
|
|
|
|
versions lie about the page size, so it is possible that
|
|
|
|
.B mkswap
|
2010-06-20 07:39:59 -05:00
|
|
|
gets it wrong. The symptom is that a subsequent
|
2006-12-06 17:25:41 -06:00
|
|
|
.B swapon
|
2010-06-20 07:39:59 -05:00
|
|
|
fails because no swap signature is found. Typical values for
|
2006-12-06 17:25:41 -06:00
|
|
|
.I PSZ
|
|
|
|
are 4096 or 8192.
|
|
|
|
|
2009-03-13 08:31:31 -05:00
|
|
|
After creating the swap area, you need the
|
|
|
|
.B swapon
|
2010-06-20 07:39:59 -05:00
|
|
|
command to start using it. Usually swap areas are listed in
|
2009-03-13 08:31:31 -05:00
|
|
|
.I /etc/fstab
|
|
|
|
so that they can be taken into use at boot time by a
|
|
|
|
.B swapon -a
|
|
|
|
command in some boot script.
|
|
|
|
|
|
|
|
.SH WARNING
|
2010-06-20 07:39:59 -05:00
|
|
|
The swap header does not touch the first block. A boot loader or disk label
|
|
|
|
can be there, but it is not a recommended setup. The recommended setup is to
|
2009-03-13 08:31:31 -05:00
|
|
|
use a separate partition for a Linux swap area.
|
|
|
|
|
2010-06-20 07:39:59 -05:00
|
|
|
.B mkswap, like many others mkfs-like utils, erases the first block to remove
|
2009-03-13 08:31:31 -05:00
|
|
|
.B old on-disk filesystems.
|
|
|
|
|
|
|
|
.B mkswap
|
|
|
|
refuses to erase the first block on a device with a disk
|
2010-06-20 07:39:59 -05:00
|
|
|
label (SUN, BSD, ...) or on a whole disk (e.g. /dev/sda).
|
2009-03-13 08:31:31 -05:00
|
|
|
|
|
|
|
.SH OPTIONS
|
|
|
|
.TP
|
|
|
|
.B \-c
|
|
|
|
Check the device (if it is a block device) for bad blocks
|
|
|
|
before creating the swap area.
|
|
|
|
If any are found, the count is printed.
|
|
|
|
.TP
|
|
|
|
.B \-f
|
2010-06-20 07:39:59 -05:00
|
|
|
Force -- go ahead even if the command is stupid.
|
2009-03-13 08:31:31 -05:00
|
|
|
This allows the creation of a swap area larger than the file
|
|
|
|
or partition it resides on.
|
|
|
|
|
2010-06-20 07:39:59 -05:00
|
|
|
Without this option,
|
2009-03-13 08:31:31 -05:00
|
|
|
.B mkswap
|
|
|
|
will refuse to erase the first block on a device with a partition table or on
|
2010-06-20 07:39:59 -05:00
|
|
|
a whole disk (e.g. /dev/sda).
|
|
|
|
.TP
|
|
|
|
.BI \-L \ label
|
|
|
|
Specify a label, to allow
|
|
|
|
.B swapon
|
|
|
|
by label.
|
2009-03-13 08:31:31 -05:00
|
|
|
.TP
|
2009-07-22 04:29:04 -05:00
|
|
|
.BI \-p \ PSZ
|
2010-06-20 07:39:59 -05:00
|
|
|
Specify the page size (in bytes) to use. This option is usually unnecessary,
|
2010-06-17 04:15:40 -05:00
|
|
|
.B mkswap
|
2010-06-20 07:39:59 -05:00
|
|
|
reads the size from the kernel.
|
2009-03-13 08:31:31 -05:00
|
|
|
.TP
|
2010-06-20 07:39:59 -05:00
|
|
|
.BI \-U \ uuid
|
|
|
|
Specify the uuid to use. The default is to generate a UUID.
|
2009-03-13 08:31:31 -05:00
|
|
|
.TP
|
2010-06-20 07:39:59 -05:00
|
|
|
.BR \-v1
|
|
|
|
Specify the swap-space version. The old \-v0 option has become obsolete
|
|
|
|
and now only \-v1 is supported.
|
2009-03-13 08:31:31 -05:00
|
|
|
|
2010-06-20 07:39:59 -05:00
|
|
|
The kernel has not supported v0 swap-space format since 2.5.22.
|
|
|
|
The new version v1 is supported since 2.1.117.
|
2006-12-06 17:27:06 -06:00
|
|
|
|
2009-03-13 08:31:31 -05:00
|
|
|
.SH NOTES
|
2006-12-06 17:27:06 -06:00
|
|
|
The maximum useful size of a swap area depends on the architecture and
|
|
|
|
the kernel version.
|
2010-06-20 07:39:59 -05:00
|
|
|
It is roughly 2GiB on i386, PPC, m68k and ARM, 1GiB on sparc, 512MiB on mips,
|
|
|
|
128GiB on alpha, and 3TiB on sparc64. For kernels after 2.3.3 there is no
|
2006-12-06 17:27:06 -06:00
|
|
|
such limitation.
|
2006-12-06 17:25:33 -06:00
|
|
|
|
2010-06-20 07:39:59 -05:00
|
|
|
Note that before version 2.1.117 the kernel allocated one byte for each page,
|
|
|
|
while it now allocates two bytes, so that taking into use a swap area of 2 GiB
|
|
|
|
might require 2 MiB of kernel memory.
|
2006-12-06 17:25:33 -06:00
|
|
|
|
2006-12-06 17:26:05 -06:00
|
|
|
Presently, Linux allows 32 swap areas (this was 8 before Linux 2.4.10).
|
|
|
|
The areas in use can be seen in the file
|
2006-12-06 17:25:37 -06:00
|
|
|
.I /proc/swaps
|
|
|
|
(since 2.1.25).
|
2006-12-06 17:25:33 -06:00
|
|
|
|
2006-12-06 17:25:37 -06:00
|
|
|
.B mkswap
|
|
|
|
refuses areas smaller than 10 pages.
|
2006-12-06 17:25:33 -06:00
|
|
|
|
2006-12-06 17:25:37 -06:00
|
|
|
If you don't know the page size that your machine uses, you may be
|
2010-06-20 07:39:59 -05:00
|
|
|
able to look it up with "cat /proc/cpuinfo" (or you may not --
|
2006-12-06 17:25:37 -06:00
|
|
|
the contents of this file depend on architecture and kernel version).
|
2006-12-06 17:25:33 -06:00
|
|
|
|
2010-06-20 07:39:59 -05:00
|
|
|
To set up a swap file, it is necessary to create that file before
|
2006-12-06 17:25:43 -06:00
|
|
|
initializing it with
|
2009-07-22 04:29:04 -05:00
|
|
|
.BR mkswap ,
|
2006-12-06 17:25:37 -06:00
|
|
|
e.g. using a command like
|
2006-12-06 17:25:32 -06:00
|
|
|
|
|
|
|
.nf
|
|
|
|
.RS
|
2006-12-06 17:25:37 -06:00
|
|
|
# dd if=/dev/zero of=swapfile bs=1024 count=65536
|
2006-12-06 17:25:32 -06:00
|
|
|
.RE
|
|
|
|
.fi
|
|
|
|
|
2006-12-06 17:25:33 -06:00
|
|
|
Note that a swap file must not contain any holes (so, using
|
2006-12-06 17:25:32 -06:00
|
|
|
.BR cp (1)
|
|
|
|
to create the file is not acceptable).
|
|
|
|
|
2008-01-27 00:31:06 -06:00
|
|
|
|
2006-12-06 17:25:32 -06:00
|
|
|
.SH "SEE ALSO"
|
2006-12-06 17:25:37 -06:00
|
|
|
.BR fdisk (8),
|
|
|
|
.BR swapon (8)
|
2007-07-02 18:17:04 -05:00
|
|
|
.SH AVAILABILITY
|
|
|
|
The mkswap command is part of the util-linux-ng package and is available from
|
|
|
|
ftp://ftp.kernel.org/pub/linux/utils/util-linux-ng/.
|