]>
Commit | Line | Data |
---|---|---|
5c36a0eb KZ |
1 | .\" Copyright 1998 Andries E. Brouwer (aeb@cwi.nl) |
2 | .\" | |
6dbe3af9 | 3 | .\" May be distributed under the GNU General Public License |
5c36a0eb | 4 | .\" |
232dc924 | 5 | .TH MKSWAP 8 "March 2009" "util-linux" "System Administration" |
6dbe3af9 | 6 | .SH NAME |
726f69e2 | 7 | mkswap \- set up a Linux swap area |
6dbe3af9 | 8 | .SH SYNOPSIS |
e584ccb8 | 9 | .B mkswap |
f49ccec2 | 10 | [options] |
449a215f BS |
11 | .I device |
12 | .RI [ size ] | |
6dbe3af9 KZ |
13 | .SH DESCRIPTION |
14 | .B mkswap | |
726f69e2 | 15 | sets up a Linux swap area on a device or in a file. |
6dbe3af9 KZ |
16 | |
17 | The | |
18 | .I device | |
5c36a0eb | 19 | argument will usually be a disk partition (something like |
5c36a0eb KZ |
20 | .IR /dev/sdb7 ) |
21 | but can also be a file. | |
83ff3782 | 22 | The Linux kernel does not look at partition IDs, but |
5c36a0eb KZ |
23 | many installation scripts will assume that partitions |
24 | of hex type 82 (LINUX_SWAP) are meant to be swap partitions. | |
83ff3782 | 25 | (\fBWarning: Solaris also uses this type. Be careful not to kill |
d10056b3 | 26 | your Solaris partitions.\fP) |
6dbe3af9 KZ |
27 | |
28 | The | |
5c36a0eb KZ |
29 | .I size |
30 | parameter is superfluous but retained for backwards compatibility. | |
31 | (It specifies the desired size of the swap area in 1024-byte blocks. | |
726f69e2 | 32 | .B mkswap |
7eda085c | 33 | will use the entire partition or file if it is omitted. |
96979754 | 34 | Specifying it is unwise \(en a typo may destroy your disk.) |
726f69e2 | 35 | |
d10056b3 KZ |
36 | After creating the swap area, you need the |
37 | .B swapon | |
83ff3782 | 38 | command to start using it. Usually swap areas are listed in |
d10056b3 KZ |
39 | .I /etc/fstab |
40 | so that they can be taken into use at boot time by a | |
96979754 | 41 | .B swapon \-a |
d10056b3 KZ |
42 | command in some boot script. |
43 | ||
44 | .SH WARNING | |
83ff3782 BS |
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 | |
d10056b3 KZ |
47 | use a separate partition for a Linux swap area. |
48 | ||
449a215f BS |
49 | .BR mkswap , |
50 | like many others mkfs-like utils, | |
51 | .B erases the first partition block to make any previous filesystem invisible. | |
d10056b3 | 52 | |
449a215f | 53 | However, |
d10056b3 KZ |
54 | .B mkswap |
55 | refuses to erase the first block on a device with a disk | |
96979754 | 56 | label (SUN, BSD, \&...\&). |
d10056b3 KZ |
57 | |
58 | .SH OPTIONS | |
59 | .TP | |
17945af6 | 60 | .BR \-c , " \-\-check" |
d10056b3 KZ |
61 | Check the device (if it is a block device) for bad blocks |
62 | before creating the swap area. | |
449a215f | 63 | If any bad blocks are found, the count is printed. |
d10056b3 | 64 | .TP |
17945af6 | 65 | .BR \-f , " \-\-force" |
449a215f | 66 | Go ahead even if the command is stupid. |
d10056b3 KZ |
67 | This allows the creation of a swap area larger than the file |
68 | or partition it resides on. | |
69 | ||
449a215f | 70 | Also, without this option, |
d10056b3 | 71 | .B mkswap |
c1f1b301 | 72 | will refuse to erase the first block on a device with a partition table. |
83ff3782 | 73 | .TP |
449a215f BS |
74 | .BR \-L , " \-\-label " \fIlabel\fR |
75 | Specify a \fIlabel\fR for the device, to allow | |
83ff3782 BS |
76 | .B swapon |
77 | by label. | |
d10056b3 | 78 | .TP |
449a215f BS |
79 | .BR \-p , " \-\-pagesize " \fIsize\fR |
80 | Specify the page \fIsize\fR (in bytes) to use. This option is usually unnecessary; | |
c4c20b3a | 81 | .B mkswap |
83ff3782 | 82 | reads the size from the kernel. |
d10056b3 | 83 | .TP |
449a215f BS |
84 | .BR \-U , " \-\-uuid " \fIUUID\fR |
85 | Specify the \fIUUID\fR to use. The default is to generate a UUID. | |
d10056b3 | 86 | .TP |
449a215f BS |
87 | .BR \-v , " \-\-swapversion 1" |
88 | Specify the swap-space version. (This option is currently pointless, as the old | |
89 | .B \-v 0 | |
90 | option has become obsolete and now only | |
91 | .B \-v 1 | |
92 | is supported. | |
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).) | |
17945af6 | 95 | .TP |
17945af6 | 96 | .BR \-h , " \-\-help" |
449a215f BS |
97 | Display help text and exit. |
98 | .TP | |
99 | .BR \-V , " \-\-version" | |
100 | Display version information and exit. | |
ca3ea756 | 101 | |
d10056b3 | 102 | .SH NOTES |
ca3ea756 KZ |
103 | The maximum useful size of a swap area depends on the architecture and |
104 | the kernel version. | |
726f69e2 | 105 | |
f1477c4b | 106 | The maximum number of the pages that is possible to address by swap area header |
96979754 | 107 | is 4294967295 (UINT_MAX). The remaining space on the swap device is ignored. |
f1477c4b | 108 | |
d9ba898a | 109 | Presently, Linux allows 32 swap areas. |
95f1bdee | 110 | The areas in use can be seen in the file |
5c36a0eb | 111 | .I /proc/swaps |
726f69e2 | 112 | |
5c36a0eb KZ |
113 | .B mkswap |
114 | refuses areas smaller than 10 pages. | |
726f69e2 | 115 | |
5c36a0eb | 116 | If you don't know the page size that your machine uses, you may be |
96979754 | 117 | able to look it up with "cat /proc/cpuinfo" (or you may not \(en |
5c36a0eb | 118 | the contents of this file depend on architecture and kernel version). |
726f69e2 | 119 | |
83ff3782 | 120 | To set up a swap file, it is necessary to create that file before |
22853e4a | 121 | initializing it with |
e584ccb8 | 122 | .BR mkswap , |
96979754 | 123 | e.g.\& using a command like |
6dbe3af9 KZ |
124 | |
125 | .nf | |
126 | .RS | |
96979754 | 127 | # fallocate \-\-length 8GiB swapfile |
6dbe3af9 KZ |
128 | .RE |
129 | .fi | |
130 | ||
55034ed0 | 131 | Note that a swap file must not contain any holes. Using |
6dbe3af9 | 132 | .BR cp (1) |
55034ed0 SK |
133 | to create the file is not acceptable. Neither is use of |
134 | .BR fallocate (1) | |
135 | on file systems that support preallocated files, such as | |
136 | .BR XFS " or " ext4 , | |
137 | or on copy-on-write filesystems like | |
138 | .BR btrfs . | |
139 | It is recommended to use | |
140 | .BR dd (1) | |
141 | and /dev/zero in these cases. Please read notes from | |
142 | .BR swapon (8) | |
143 | before adding a swap file to copy-on-write filesystems. | |
6dbe3af9 | 144 | |
ddfeda98 | 145 | .SH ENVIRONMENT |
68e422ec KZ |
146 | .IP LIBBLKID_DEBUG=all |
147 | enables libblkid debug output. | |
93bf0f28 | 148 | |
6dbe3af9 | 149 | .SH "SEE ALSO" |
5c36a0eb KZ |
150 | .BR fdisk (8), |
151 | .BR swapon (8) | |
86d62711 | 152 | .SH AVAILABILITY |
601d12fb | 153 | The mkswap command is part of the util-linux package and is available from |
d673b74e | 154 | https://www.kernel.org/pub/linux/utils/util-linux/. |