]>
Commit | Line | Data |
---|---|---|
295b3979 | 1 | //po4a: entry man manual |
c6a568fc MB |
2 | //// |
3 | Copyright 1998 Andries E. Brouwer (aeb@cwi.nl) | |
4 | May be distributed under the GNU General Public License | |
5 | //// | |
6 | = mkswap(8) | |
7 | :doctype: manpage | |
8 | :man manual: System Administration | |
9 | :man source: util-linux {release-version} | |
10 | :page-layout: base | |
11 | :command: mkswap | |
12 | ||
13 | == NAME | |
14 | ||
15 | mkswap - set up a Linux swap area | |
16 | ||
17 | == SYNOPSIS | |
18 | ||
4d297435 | 19 | *mkswap* [options] _device_ [_size_] |
c6a568fc MB |
20 | |
21 | == DESCRIPTION | |
22 | ||
23 | *mkswap* sets up a Linux swap area on a device or in a file. | |
24 | ||
25 | The _device_ argument will usually be a disk partition (something like _/dev/sdb7_) but can also be a file. The Linux kernel does not look at partition IDs, but many installation scripts will assume that partitions of hex type 82 (LINUX_SWAP) are meant to be swap partitions. (*Warning: Solaris also uses this type. Be careful not to kill your Solaris partitions.*) | |
26 | ||
27 | The _size_ parameter is superfluous but retained for backwards compatibility. (It specifies the desired size of the swap area in 1024-byte blocks. *mkswap* will use the entire partition or file if it is omitted. Specifying it is unwise - a typo may destroy your disk.) | |
28 | ||
e6743239 | 29 | After creating the swap area, you need the *swapon*(8) command to start using it. Usually swap areas are listed in _/etc/fstab_ so that they can be taken into use at boot time by a *swapon -a* command in some boot script. |
c6a568fc MB |
30 | |
31 | == WARNING | |
32 | ||
33 | The swap header does not touch the first block. A boot loader or disk label can be there, but it is not a recommended setup. The recommended setup is to use a separate partition for a Linux swap area. | |
34 | ||
35 | *mkswap*, like many others mkfs-like utils, *erases the first partition block to make any previous filesystem invisible.* | |
36 | ||
37 | However, *mkswap* refuses to erase the first block on a device with a disk label (SUN, BSD, ...). | |
38 | ||
39 | == OPTIONS | |
40 | ||
41 | *-c*, *--check*:: | |
299604dd | 42 | Check the device (if it is a block device) for bad blocks before creating the swap area. If any bad blocks are found, the count is printed. |
c6a568fc MB |
43 | |
44 | *-f*, *--force*:: | |
299604dd MB |
45 | Go ahead even if the command is stupid. This allows the creation of a swap area larger than the file or partition it resides on. |
46 | + | |
47 | Also, without this option, *mkswap* will refuse to erase the first block on a device with a partition table. | |
c6a568fc | 48 | |
1f17eefb KZ |
49 | *-q*, *--quiet*:: |
50 | Suppress output and warning messages. | |
51 | ||
c6a568fc | 52 | *-L*, *--label* _label_:: |
e6743239 | 53 | Specify a _label_ for the device, to allow *swapon*(8) by label. |
c6a568fc MB |
54 | |
55 | *--lock*[=_mode_]:: | |
bd67ca44 | 56 | Use exclusive BSD lock for device or file it operates. The optional argument _mode_ can be *yes*, *no* (or 1 and 0) or *nonblock*. If the _mode_ argument is omitted, it defaults to *yes*. This option overwrites environment variable *$LOCK_BLOCK_DEVICE*. The default is not to use any lock at all, but it's recommended to avoid collisions with *systemd-udevd*(8) or other tools. |
c6a568fc MB |
57 | |
58 | *-p*, *--pagesize* _size_:: | |
299604dd | 59 | Specify the page _size_ (in bytes) to use. This option is usually unnecessary; *mkswap* reads the size from the kernel. |
c6a568fc MB |
60 | |
61 | *-U*, *--uuid* _UUID_:: | |
54ef08ed KZ |
62 | Specify the _UUID_ to use. The default is to generate a UUID. The format of the UUID is a series of |
63 | hex digits separated by hyphens, like this: "c1b9d5a2-f162-11cf-9ece-0020afc76f16". The UUID parameter | |
64 | may also be one of the following: | |
65 | + | |
66 | *clear*;; | |
67 | clear the filesystem UUID | |
68 | *random*;; | |
69 | generate a new randomly-generated UUID | |
70 | *time*;; | |
71 | generate a new time-based UUID | |
c6a568fc MB |
72 | |
73 | *-v*, *--swapversion 1*:: | |
299604dd | 74 | Specify the swap-space version. (This option is currently pointless, as the old *-v 0* option has become obsolete and now only *-v 1* is supported. The kernel has not supported v0 swap-space format since 2.5.22 (June 2002). The new version v1 is supported since 2.1.117 (August 1998).) |
c6a568fc MB |
75 | |
76 | *--verbose*:: | |
299604dd | 77 | Verbose execution. With this option *mkswap* will output more details about detected problems during swap area set up. |
c6a568fc | 78 | |
2b2d3172 | 79 | include::man-common/help-version.adoc[] |
c6a568fc MB |
80 | |
81 | == ENVIRONMENT | |
82 | ||
83 | LIBBLKID_DEBUG=all:: | |
299604dd | 84 | enables libblkid debug output. |
c6a568fc MB |
85 | |
86 | LOCK_BLOCK_DEVICE=<mode>:: | |
299604dd | 87 | use exclusive BSD lock. The mode is "1" or "0". See *--lock* for more details. |
c6a568fc MB |
88 | |
89 | == NOTES | |
90 | ||
91 | The maximum useful size of a swap area depends on the architecture and the kernel version. | |
92 | ||
93 | The maximum number of the pages that is possible to address by swap area header is 4294967295 (32-bit unsigned int). The remaining space on the swap device is ignored. | |
94 | ||
95 | Presently, Linux allows 32 swap areas. The areas in use can be seen in the file _/proc/swaps_. | |
96 | ||
97 | *mkswap* refuses areas smaller than 10 pages. | |
98 | ||
7167a454 | 99 | If you don't know the page size that your machine uses, you can look it up with *getconf PAGESIZE*. |
c6a568fc MB |
100 | |
101 | To set up a swap file, it is necessary to create that file before initializing it with *mkswap*, e.g. using a command like | |
102 | ||
103 | .... | |
104 | # dd if=/dev/zero of=swapfile bs=1MiB count=$((8*1024)) | |
105 | .... | |
106 | ||
107 | to create 8GiB swapfile. | |
108 | ||
109 | Please read notes from *swapon*(8) about *the swap file use restrictions* (holes, preallocation and copy-on-write issues). | |
110 | ||
111 | == SEE ALSO | |
112 | ||
113 | *fdisk*(8), | |
114 | *swapon*(8) | |
115 | ||
625e9c61 | 116 | include::man-common/bugreports.adoc[] |
c6a568fc | 117 | |
625e9c61 | 118 | include::man-common/footer.adoc[] |
c6a568fc MB |
119 | |
120 | ifdef::translation[] | |
625e9c61 | 121 | include::man-common/translation.adoc[] |
c6a568fc | 122 | endif::[] |