]>
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 | 72 | |
2a80192f TW |
73 | *-e*, *--endianness* _ENDIANNESS_:: |
74 | Specify the _ENDIANNESS_ to use, valid arguments are *native*, *little* or *big*. The default is *native*. | |
75 | ||
84ec6f99 TW |
76 | *-o*, *--offset* _offset_:: |
77 | Specify the _offset_ to write the swap area to. | |
78 | ||
c6a568fc | 79 | *-v*, *--swapversion 1*:: |
299604dd | 80 | 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 |
81 | |
82 | *--verbose*:: | |
299604dd | 83 | Verbose execution. With this option *mkswap* will output more details about detected problems during swap area set up. |
c6a568fc | 84 | |
2b2d3172 | 85 | include::man-common/help-version.adoc[] |
c6a568fc MB |
86 | |
87 | == ENVIRONMENT | |
88 | ||
89 | LIBBLKID_DEBUG=all:: | |
299604dd | 90 | enables libblkid debug output. |
c6a568fc MB |
91 | |
92 | LOCK_BLOCK_DEVICE=<mode>:: | |
299604dd | 93 | use exclusive BSD lock. The mode is "1" or "0". See *--lock* for more details. |
c6a568fc MB |
94 | |
95 | == NOTES | |
96 | ||
97 | The maximum useful size of a swap area depends on the architecture and the kernel version. | |
98 | ||
99 | 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. | |
100 | ||
101 | Presently, Linux allows 32 swap areas. The areas in use can be seen in the file _/proc/swaps_. | |
102 | ||
103 | *mkswap* refuses areas smaller than 10 pages. | |
104 | ||
7167a454 | 105 | If you don't know the page size that your machine uses, you can look it up with *getconf PAGESIZE*. |
c6a568fc MB |
106 | |
107 | To set up a swap file, it is necessary to create that file before initializing it with *mkswap*, e.g. using a command like | |
108 | ||
109 | .... | |
110 | # dd if=/dev/zero of=swapfile bs=1MiB count=$((8*1024)) | |
111 | .... | |
112 | ||
113 | to create 8GiB swapfile. | |
114 | ||
115 | Please read notes from *swapon*(8) about *the swap file use restrictions* (holes, preallocation and copy-on-write issues). | |
116 | ||
117 | == SEE ALSO | |
118 | ||
119 | *fdisk*(8), | |
120 | *swapon*(8) | |
121 | ||
625e9c61 | 122 | include::man-common/bugreports.adoc[] |
c6a568fc | 123 | |
625e9c61 | 124 | include::man-common/footer.adoc[] |
c6a568fc MB |
125 | |
126 | ifdef::translation[] | |
625e9c61 | 127 | include::man-common/translation.adoc[] |
c6a568fc | 128 | endif::[] |