1 .\" Copyright 1998 Andries E. Brouwer (aeb@cwi.nl)
3 .\" May be distributed under the GNU General Public License
4 .\" Rewritten for 2.1.117, aeb, 981010.
6 .TH MKSWAP 8 "13 March 2009" "Linux" "Linux Programmer's Manual"
8 mkswap \- set up a Linux swap area
23 sets up a Linux swap area on a device or in a file.
27 argument will usually be a disk partition (something like
29 but can also be a file.
30 The Linux kernel does not look at partition Id's, but
31 many installation scripts will assume that partitions
32 of hex type 82 (LINUX_SWAP) are meant to be swap partitions.
33 (\fBWarning: Solaris also uses this type. Be careful not to kill
34 your Solaris partitions.\fP)
38 parameter is superfluous but retained for backwards compatibility.
39 (It specifies the desired size of the swap area in 1024-byte blocks.
41 will use the entire partition or file if it is omitted.
42 Specifying it is unwise - a typo may destroy your disk.)
46 parameter specifies the page size to use. It is almost always
47 unnecessary (even unwise) to specify it, but certain old libc
48 versions lie about the page size, so it is possible that
50 gets it wrong. The symptom is that a subsequent
52 fails because no swap signature is found. Typical values for
56 After creating the swap area, you need the
58 command to start using it. Usually swap areas are listed in
60 so that they can be taken into use at boot time by a
62 command in some boot script.
65 The swap header does not touch the first block. A boot loader or disk label
66 can be there, but it is not recommended setup. The recommended setup is to
67 use a separate partition for a Linux swap area.
69 .B mkswap like many others mkfs-like utils erases the first block to remove
70 .B old on-disk filesystems.
73 refuses to erase the first block on a device with a disk
74 label (SUN, BSD, ...) or on whole disk (e.g. /dev/sda).
79 Check the device (if it is a block device) for bad blocks
80 before creating the swap area.
81 If any are found, the count is printed.
84 Force - go ahead even if the command is stupid.
85 This allows the creation of a swap area larger than the file
86 or partition it resides on.
90 will refuse to erase the first block on a device with a partition table or on
91 whole disk (e.g. /dec/sda).
94 Specify the page size to use.
97 Specify a label, to allow swapon by label.
98 (Only for new style swap areas.)
101 Specify the swap space version. This option is deprecated and \-v1 is
104 The kernel has not supported v0 swap space format since 2.5.22. The new version
105 v1 is supported since 2.1.117.
109 Specify the uuid to use. The default is to generate UUIDs.
112 The maximum useful size of a swap area depends on the architecture and
114 It is roughly 2GiB on i386, PPC, m68k, ARM, 1GiB on sparc, 512MiB on mips,
115 128GiB on alpha and 3TiB on sparc64. For kernels after 2.3.3 there is no
118 Note that before 2.1.117 the kernel allocated one byte for each page,
119 while it now allocates two bytes, so that taking a swap area of 2 GiB
120 in use might require 2 MiB of kernel memory.
122 Presently, Linux allows 32 swap areas (this was 8 before Linux 2.4.10).
123 The areas in use can be seen in the file
128 refuses areas smaller than 10 pages.
130 If you don't know the page size that your machine uses, you may be
131 able to look it up with "cat /proc/cpuinfo" (or you may not -
132 the contents of this file depend on architecture and kernel version).
134 To setup a swap file, it is necessary to create that file before
137 e.g. using a command like
141 # dd if=/dev/zero of=swapfile bs=1024 count=65536
145 Note that a swap file must not contain any holes (so, using
147 to create the file is not acceptable).
154 The mkswap command is part of the util-linux-ng package and is available from
155 ftp://ftp.kernel.org/pub/linux/utils/util-linux-ng/.