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 "March 2009" "util-linux" "System Administration"
8 mkswap \- set up a Linux swap area
16 sets up a Linux swap area on a device or in a file.
20 argument will usually be a disk partition (something like
22 but can also be a file.
23 The Linux kernel does not look at partition IDs, but
24 many installation scripts will assume that partitions
25 of hex type 82 (LINUX_SWAP) are meant to be swap partitions.
26 (\fBWarning: Solaris also uses this type. Be careful not to kill
27 your Solaris partitions.\fP)
31 parameter is superfluous but retained for backwards compatibility.
32 (It specifies the desired size of the swap area in 1024-byte blocks.
34 will use the entire partition or file if it is omitted.
35 Specifying it is unwise -- a typo may destroy your disk.)
37 After creating the swap area, you need the
39 command to start using it. Usually swap areas are listed in
41 so that they can be taken into use at boot time by a
43 command in some boot script.
46 The swap header does not touch the first block. A boot loader or disk label
47 can be there, but it is not a recommended setup. The recommended setup is to
48 use a separate partition for a Linux swap area.
51 like many others mkfs-like utils,
52 .B erases the first partition block to make any previous filesystem invisible.
56 refuses to erase the first block on a device with a disk
57 label (SUN, BSD, ...).
61 .BR \-c , " \-\-check"
62 Check the device (if it is a block device) for bad blocks
63 before creating the swap area.
64 If any bad blocks are found, the count is printed.
66 .BR \-f , " \-\-force"
67 Go ahead even if the command is stupid.
68 This allows the creation of a swap area larger than the file
69 or partition it resides on.
71 Also, without this option,
73 will refuse to erase the first block on a device with a partition table.
75 .BR \-L , " \-\-label " \fIlabel\fR
76 Specify a \fIlabel\fR for the device, to allow
80 .BR \-p , " \-\-pagesize " \fIsize\fR
81 Specify the page \fIsize\fR (in bytes) to use. This option is usually unnecessary;
83 reads the size from the kernel.
85 .BR \-U , " \-\-uuid " \fIUUID\fR
86 Specify the \fIUUID\fR to use. The default is to generate a UUID.
88 .BR \-v , " \-\-swapversion 1"
89 Specify the swap-space version. (This option is currently pointless, as the old
91 option has become obsolete and now only
94 The kernel has not supported v0 swap-space format since 2.5.22 (June 2002).
95 The new version v1 is supported since 2.1.117 (August 1998).)
98 Display help text and exit.
100 .BR \-V , " \-\-version"
101 Display version information and exit.
104 The maximum useful size of a swap area depends on the architecture and
106 It is roughly 2GiB on i386, PPC, m68k and ARM, 1GiB on sparc, 512MiB on mips,
107 128GiB on alpha, and 3TiB on sparc64. For kernels after 2.3.3 (May 1999) there is no
110 Note that before version 2.1.117 the kernel allocated one byte for each page,
111 while it now allocates two bytes, so that taking into use a swap area of 2 GiB
112 might require 2 MiB of kernel memory.
114 Presently, Linux allows 32 swap areas (this was 8 before Linux 2.4.10 (Sep 2001)).
115 The areas in use can be seen in the file
117 (since 2.1.25 (Sep 1997)).
120 refuses areas smaller than 10 pages.
122 If you don't know the page size that your machine uses, you may be
123 able to look it up with "cat /proc/cpuinfo" (or you may not --
124 the contents of this file depend on architecture and kernel version).
126 To set up a swap file, it is necessary to create that file before
129 e.g. using a command like
133 # dd if=/dev/zero of=swapfile bs=1024 count=65536
137 Note that a swap file must not contain any holes (so, using
139 to create the file is not acceptable).
142 .IP LIBBLKID_DEBUG=0xffff
143 enables debug output.
149 The mkswap command is part of the util-linux package and is available from
150 ftp://ftp.kernel.org/pub/linux/utils/util-linux/.