]> git.ipfire.org Git - thirdparty/util-linux.git/blob - disk-utils/mkswap.8
mkswap: wipe old signature if there is no part table by default
[thirdparty/util-linux.git] / disk-utils / mkswap.8
1 .\" Copyright 1998 Andries E. Brouwer (aeb@cwi.nl)
2 .\"
3 .\" May be distributed under the GNU General Public License
4 .\" Rewritten for 2.1.117, aeb, 981010.
5 .\"
6 .TH MKSWAP 8 "March 2009" "util-linux" "System Administration"
7 .SH NAME
8 mkswap \- set up a Linux swap area
9 .SH SYNOPSIS
10 .B mkswap
11 .RI [ options ]
12 .I device
13 .RI [ size ]
14 .SH DESCRIPTION
15 .B mkswap
16 sets up a Linux swap area on a device or in a file.
17
18 The
19 .I device
20 argument will usually be a disk partition (something like
21 .IR /dev/sdb7 )
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)
28
29 The
30 .I size
31 parameter is superfluous but retained for backwards compatibility.
32 (It specifies the desired size of the swap area in 1024-byte blocks.
33 .B mkswap
34 will use the entire partition or file if it is omitted.
35 Specifying it is unwise -- a typo may destroy your disk.)
36
37 After creating the swap area, you need the
38 .B swapon
39 command to start using it. Usually swap areas are listed in
40 .I /etc/fstab
41 so that they can be taken into use at boot time by a
42 .B swapon -a
43 command in some boot script.
44
45 .SH WARNING
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.
49
50 .BR mkswap ,
51 like many others mkfs-like utils,
52 .B erases the first partition block to make any previous filesystem invisible.
53
54 However,
55 .B mkswap
56 refuses to erase the first block on a device with a disk
57 label (SUN, BSD, ...).
58
59 .SH OPTIONS
60 .TP
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.
65 .TP
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.
70
71 Also, without this option,
72 .B mkswap
73 will refuse to erase the first block on a device with a partition table.
74 .TP
75 .BR \-L , " \-\-label " \fIlabel\fR
76 Specify a \fIlabel\fR for the device, to allow
77 .B swapon
78 by label.
79 .TP
80 .BR \-p , " \-\-pagesize " \fIsize\fR
81 Specify the page \fIsize\fR (in bytes) to use. This option is usually unnecessary;
82 .B mkswap
83 reads the size from the kernel.
84 .TP
85 .BR \-U , " \-\-uuid " \fIUUID\fR
86 Specify the \fIUUID\fR to use. The default is to generate a UUID.
87 .TP
88 .BR \-v , " \-\-swapversion 1"
89 Specify the swap-space version. (This option is currently pointless, as the old
90 .B \-v 0
91 option has become obsolete and now only
92 .B \-v 1
93 is supported.
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).)
96 .TP
97 .BR \-h , " \-\-help"
98 Display help text and exit.
99 .TP
100 .BR \-V , " \-\-version"
101 Display version information and exit.
102
103 .SH NOTES
104 The maximum useful size of a swap area depends on the architecture and
105 the kernel version.
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
108 such limitation.
109
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.
113
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
116 .I /proc/swaps
117 (since 2.1.25 (Sep 1997)).
118
119 .B mkswap
120 refuses areas smaller than 10 pages.
121
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).
125
126 To set up a swap file, it is necessary to create that file before
127 initializing it with
128 .BR mkswap ,
129 e.g. using a command like
130
131 .nf
132 .RS
133 # dd if=/dev/zero of=swapfile bs=1024 count=65536
134 .RE
135 .fi
136
137 Note that a swap file must not contain any holes (so, using
138 .BR cp (1)
139 to create the file is not acceptable).
140
141 .SH ENVIRONMENT
142 .IP LIBBLKID_DEBUG=0xffff
143 enables debug output.
144
145 .SH "SEE ALSO"
146 .BR fdisk (8),
147 .BR swapon (8)
148 .SH AVAILABILITY
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/.