1 .\" Copyright 1998 Andries E. Brouwer (aeb@cwi.nl)
3 .\" May be distributed under the GNU General Public License
5 .TH MKSWAP 8 "March 2009" "util-linux" "System Administration"
7 mkswap \- set up a Linux swap area
15 sets up a Linux swap area on a device or in a file.
19 argument will usually be a disk partition (something like
21 but can also be a file.
22 The Linux kernel does not look at partition IDs, but
23 many installation scripts will assume that partitions
24 of hex type 82 (LINUX_SWAP) are meant to be swap partitions.
25 (\fBWarning: Solaris also uses this type. Be careful not to kill
26 your Solaris partitions.\fP)
30 parameter is superfluous but retained for backwards compatibility.
31 (It specifies the desired size of the swap area in 1024-byte blocks.
33 will use the entire partition or file if it is omitted.
34 Specifying it is unwise \(en a typo may destroy your disk.)
36 After creating the swap area, you need the
38 command to start using it. Usually swap areas are listed in
40 so that they can be taken into use at boot time by a
42 command in some boot script.
45 The swap header does not touch the first block. A boot loader or disk label
46 can be there, but it is not a recommended setup. The recommended setup is to
47 use a separate partition for a Linux swap area.
50 like many others mkfs-like utils,
51 .B erases the first partition block to make any previous filesystem invisible.
55 refuses to erase the first block on a device with a disk
56 label (SUN, BSD, \&...\&).
60 .BR \-c , " \-\-check"
61 Check the device (if it is a block device) for bad blocks
62 before creating the swap area.
63 If any bad blocks are found, the count is printed.
65 .BR \-f , " \-\-force"
66 Go ahead even if the command is stupid.
67 This allows the creation of a swap area larger than the file
68 or partition it resides on.
70 Also, without this option,
72 will refuse to erase the first block on a device with a partition table.
74 .BR \-L , " \-\-label " \fIlabel\fR
75 Specify a \fIlabel\fR for the device, to allow
79 .BR \-p , " \-\-pagesize " \fIsize\fR
80 Specify the page \fIsize\fR (in bytes) to use. This option is usually unnecessary;
82 reads the size from the kernel.
84 .BR \-U , " \-\-uuid " \fIUUID\fR
85 Specify the \fIUUID\fR to use. The default is to generate a UUID.
87 .BR \-v , " \-\-swapversion 1"
88 Specify the swap-space version. (This option is currently pointless, as the old
90 option has become obsolete and now only
93 The kernel has not supported v0 swap-space format since 2.5.22 (June 2002).
94 The new version v1 is supported since 2.1.117 (August 1998).)
97 Display help text and exit.
99 .BR \-V , " \-\-version"
100 Display version information and exit.
103 The maximum useful size of a swap area depends on the architecture and
106 The maximum number of the pages that is possible to address by swap area header
107 is 4294967295 (UINT_MAX). The remaining space on the swap device is ignored.
109 Presently, Linux allows 32 swap areas.
110 The areas in use can be seen in the file
114 refuses areas smaller than 10 pages.
116 If you don't know the page size that your machine uses, you may be
117 able to look it up with "cat /proc/cpuinfo" (or you may not \(en
118 the contents of this file depend on architecture and kernel version).
120 To set up a swap file, it is necessary to create that file before
123 e.g.\& using a command like
127 # fallocate \-\-length 8GiB swapfile
131 Note that a swap file must not contain any holes. Using
133 to create the file is not acceptable. Neither is use of
135 on file systems that support preallocated files, such as
136 .BR XFS " or " ext4 ,
137 or on copy-on-write filesystems like
139 It is recommended to use
141 and /dev/zero in these cases. Please read notes from
143 before adding a swap file to copy-on-write filesystems.
146 .IP LIBBLKID_DEBUG=all
147 enables libblkid debug output.
153 The mkswap command is part of the util-linux package and is available from
154 ftp://ftp.kernel.org/pub/linux/utils/util-linux/.