230 lines
5.7 KiB
HTML
230 lines
5.7 KiB
HTML
|
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|
<HTML><HEAD><TITLE>Man page of MKSWAP</TITLE>
|
|
</HEAD><BODY>
|
|
<H1>MKSWAP</H1>
|
|
Section: System Administration (8)<BR>Updated: March 2009<BR><A HREF="#index">Index</A>
|
|
<A HREF="/cgi-bin/man/man2html">Return to Main Contents</A><HR>
|
|
|
|
<A NAME="lbAB"> </A>
|
|
<H2>NAME</H2>
|
|
|
|
mkswap - set up a Linux swap area
|
|
<A NAME="lbAC"> </A>
|
|
<H2>SYNOPSIS</H2>
|
|
|
|
<B>mkswap</B>
|
|
|
|
[options]
|
|
<I>device</I>
|
|
|
|
[<I>size</I>]
|
|
|
|
<A NAME="lbAD"> </A>
|
|
<H2>DESCRIPTION</H2>
|
|
|
|
<B>mkswap</B>
|
|
|
|
sets up a Linux swap area on a device or in a file.
|
|
<P>
|
|
The
|
|
<I>device</I>
|
|
|
|
argument will usually be a disk partition (something like
|
|
<I>/dev/sdb7</I>)
|
|
|
|
but can also be a file.
|
|
The Linux kernel does not look at partition IDs, but
|
|
many installation scripts will assume that partitions
|
|
of hex type 82 (LINUX_SWAP) are meant to be swap partitions.
|
|
(<B>Warning: Solaris also uses this type. Be careful not to kill
|
|
your Solaris partitions.</B>)
|
|
<P>
|
|
The
|
|
<I>size</I>
|
|
|
|
parameter is superfluous but retained for backwards compatibility.
|
|
(It specifies the desired size of the swap area in 1024-byte blocks.
|
|
<B>mkswap</B>
|
|
|
|
will use the entire partition or file if it is omitted.
|
|
Specifying it is unwise - a typo may destroy your disk.)
|
|
<P>
|
|
After creating the swap area, you need the
|
|
<B>swapon</B>
|
|
|
|
command to start using it. Usually swap areas are listed in
|
|
<I>/etc/fstab</I>
|
|
|
|
so that they can be taken into use at boot time by a
|
|
<B>swapon -a</B>
|
|
|
|
command in some boot script.
|
|
<P>
|
|
<A NAME="lbAE"> </A>
|
|
<H2>WARNING</H2>
|
|
|
|
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
|
|
use a separate partition for a Linux swap area.
|
|
<P>
|
|
<B>mkswap</B>,
|
|
|
|
like many others mkfs-like utils,
|
|
<B>erases the first partition block to make any previous filesystem invisible.</B>
|
|
|
|
<P>
|
|
However,
|
|
<B>mkswap</B>
|
|
|
|
refuses to erase the first block on a device with a disk
|
|
label (SUN, BSD, ...).
|
|
<P>
|
|
<A NAME="lbAF"> </A>
|
|
<H2>OPTIONS</H2>
|
|
|
|
<DL COMPACT>
|
|
<DT id="1"><B>-c</B>,<B> --check</B>
|
|
|
|
<DD>
|
|
Check the device (if it is a block device) for bad blocks
|
|
before creating the swap area.
|
|
If any bad blocks are found, the count is printed.
|
|
<DT id="2"><B>-f</B>,<B> --force</B>
|
|
|
|
<DD>
|
|
Go ahead even if the command is stupid.
|
|
This allows the creation of a swap area larger than the file
|
|
or partition it resides on.
|
|
<P>
|
|
Also, without this option,
|
|
<B>mkswap</B>
|
|
|
|
will refuse to erase the first block on a device with a partition table.
|
|
<DT id="3"><B>-L</B>,<B> --label </B><I>label</I>
|
|
|
|
<DD>
|
|
Specify a <I>label</I> for the device, to allow
|
|
<B>swapon</B>
|
|
|
|
by label.
|
|
<DT id="4"><B>-p</B>,<B> --pagesize </B><I>size</I>
|
|
|
|
<DD>
|
|
Specify the page <I>size</I> (in bytes) to use. This option is usually unnecessary;
|
|
<B>mkswap</B>
|
|
|
|
reads the size from the kernel.
|
|
<DT id="5"><B>-U</B>,<B> --uuid </B><I>UUID</I>
|
|
|
|
<DD>
|
|
Specify the <I>UUID</I> to use. The default is to generate a UUID.
|
|
<DT id="6"><B>-v</B>,<B> --swapversion 1</B>
|
|
|
|
<DD>
|
|
Specify the swap-space version. (This option is currently pointless, as the old
|
|
<B>-v 0</B>
|
|
|
|
option has become obsolete and now only
|
|
<B>-v 1</B>
|
|
|
|
is supported.
|
|
The kernel has not supported v0 swap-space format since 2.5.22 (June 2002).
|
|
The new version v1 is supported since 2.1.117 (August 1998).)
|
|
<DT id="7"><B>-h</B>,<B> --help</B>
|
|
|
|
<DD>
|
|
Display help text and exit.
|
|
<DT id="8"><B>-V</B>,<B> --version</B>
|
|
|
|
<DD>
|
|
Display version information and exit.
|
|
<P>
|
|
</DL>
|
|
<A NAME="lbAG"> </A>
|
|
<H2>NOTES</H2>
|
|
|
|
The maximum useful size of a swap area depends on the architecture and
|
|
the kernel version.
|
|
<P>
|
|
The maximum number of the pages that is possible to address by swap area header
|
|
is 4294967295 (32-bit unsigned int). The remaining space on the swap device is ignored.
|
|
<P>
|
|
Presently, Linux allows 32 swap areas.
|
|
The areas in use can be seen in the file
|
|
<I>/proc/swaps</I>
|
|
|
|
<P>
|
|
<B>mkswap</B>
|
|
|
|
refuses areas smaller than 10 pages.
|
|
<P>
|
|
If you don't know the page size that your machine uses, you may be
|
|
able to look it up with "cat /proc/cpuinfo" (or you may not -
|
|
the contents of this file depend on architecture and kernel version).
|
|
<P>
|
|
To set up a swap file, it is necessary to create that file before
|
|
initializing it with
|
|
<B>mkswap</B>,
|
|
|
|
e.g. using a command like
|
|
<P>
|
|
<PRE>
|
|
<DL COMPACT><DT id="9"><DD># dd if=/dev/zero of=swapfile bs=1MiB count=$((8*1024))
|
|
</DL>
|
|
</PRE>
|
|
|
|
<P>
|
|
to create 8GiB swapfile.
|
|
<P>
|
|
Please read notes from
|
|
<B><A HREF="/cgi-bin/man/man2html?8+swapon">swapon</A></B>(8)
|
|
|
|
about
|
|
<B>the swap file use restrictions</B>
|
|
|
|
(holes, preallocation and copy-on-write issues).
|
|
<P>
|
|
<A NAME="lbAH"> </A>
|
|
<H2>ENVIRONMENT</H2>
|
|
|
|
<DL COMPACT>
|
|
<DT id="10">LIBBLKID_DEBUG=all<DD>
|
|
enables libblkid debug output.
|
|
<P>
|
|
</DL>
|
|
<A NAME="lbAI"> </A>
|
|
<H2>SEE ALSO</H2>
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?8+fdisk">fdisk</A></B>(8),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?8+swapon">swapon</A></B>(8)
|
|
|
|
<A NAME="lbAJ"> </A>
|
|
<H2>AVAILABILITY</H2>
|
|
|
|
The mkswap command is part of the util-linux package and is available from
|
|
<A HREF="https://www.kernel.org/pub/linux/utils/util-linux/.">https://www.kernel.org/pub/linux/utils/util-linux/.</A>
|
|
<P>
|
|
|
|
<HR>
|
|
<A NAME="index"> </A><H2>Index</H2>
|
|
<DL>
|
|
<DT id="11"><A HREF="#lbAB">NAME</A><DD>
|
|
<DT id="12"><A HREF="#lbAC">SYNOPSIS</A><DD>
|
|
<DT id="13"><A HREF="#lbAD">DESCRIPTION</A><DD>
|
|
<DT id="14"><A HREF="#lbAE">WARNING</A><DD>
|
|
<DT id="15"><A HREF="#lbAF">OPTIONS</A><DD>
|
|
<DT id="16"><A HREF="#lbAG">NOTES</A><DD>
|
|
<DT id="17"><A HREF="#lbAH">ENVIRONMENT</A><DD>
|
|
<DT id="18"><A HREF="#lbAI">SEE ALSO</A><DD>
|
|
<DT id="19"><A HREF="#lbAJ">AVAILABILITY</A><DD>
|
|
</DL>
|
|
<HR>
|
|
This document was created by
|
|
<A HREF="/cgi-bin/man/man2html">man2html</A>,
|
|
using the manual pages.<BR>
|
|
Time: 00:06:13 GMT, March 31, 2021
|
|
</BODY>
|
|
</HTML>
|