]> git.ipfire.org Git - thirdparty/util-linux.git/blame - disk-utils/mkswap.8.adoc
hwclock: free temporary variable before return
[thirdparty/util-linux.git] / disk-utils / mkswap.8.adoc
CommitLineData
295b3979 1//po4a: entry man manual
c6a568fc
MB
2////
3Copyright 1998 Andries E. Brouwer (aeb@cwi.nl)
4May 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
15mkswap - set up a Linux swap area
16
17== SYNOPSIS
18
7377b0d9
VP
19*mkswap* [options] _device_ [_blocks_]
20
21*mkswap* [options] --size _size_ --file _file_
c6a568fc
MB
22
23== DESCRIPTION
24
25*mkswap* sets up a Linux swap area on a device or in a file.
26
27The _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.*)
28
7377b0d9 29The _blocks_ 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.)
c6a568fc 30
e6743239 31After 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
32
33== WARNING
34
35The 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.
36
37*mkswap*, like many others mkfs-like utils, *erases the first partition block to make any previous filesystem invisible.*
38
39However, *mkswap* refuses to erase the first block on a device with a disk label (SUN, BSD, ...).
40
41== OPTIONS
42
43*-c*, *--check*::
299604dd 44Check 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 45
7377b0d9
VP
46*-F*, *--file*::
47Create a swap file with the appropriate file permissions and populated blocks on disk.
48
c6a568fc 49*-f*, *--force*::
299604dd
MB
50Go ahead even if the command is stupid. This allows the creation of a swap area larger than the file or partition it resides on.
51+
52Also, without this option, *mkswap* will refuse to erase the first block on a device with a partition table.
c6a568fc 53
1f17eefb
KZ
54*-q*, *--quiet*::
55Suppress output and warning messages.
56
c6a568fc 57*-L*, *--label* _label_::
e6743239 58Specify a _label_ for the device, to allow *swapon*(8) by label.
c6a568fc
MB
59
60*--lock*[=_mode_]::
bd67ca44 61Use 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
62
63*-p*, *--pagesize* _size_::
299604dd 64Specify the page _size_ (in bytes) to use. This option is usually unnecessary; *mkswap* reads the size from the kernel.
c6a568fc
MB
65
66*-U*, *--uuid* _UUID_::
54ef08ed
KZ
67Specify the _UUID_ to use. The default is to generate a UUID. The format of the UUID is a series of
68hex digits separated by hyphens, like this: "c1b9d5a2-f162-11cf-9ece-0020afc76f16". The UUID parameter
69may also be one of the following:
70+
71*clear*;;
72clear the filesystem UUID
73*random*;;
74generate a new randomly-generated UUID
75*time*;;
76generate a new time-based UUID
c6a568fc 77
2a80192f
TW
78*-e*, *--endianness* _ENDIANNESS_::
79Specify the _ENDIANNESS_ to use, valid arguments are *native*, *little* or *big*. The default is *native*.
80
84ec6f99
TW
81*-o*, *--offset* _offset_::
82Specify the _offset_ to write the swap area to.
83
7377b0d9
VP
84*-s*, *--size* _size_::
85Specify the size of the created swap file in bytes and may be followed by a multiplicative suffix: KiB (=1024), MiB (=1024*1024), and so on for GiB, TiB, PiB, EiB, ZiB and YiB (the "iB" is optional, e.g., "K" has the same meaning as "KiB"). If the file exists and is larger than _size_, it will be truncated to this size. This option only makes sense when used with *--file*.
86
c6a568fc 87*-v*, *--swapversion 1*::
299604dd 88Specify 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
89
90*--verbose*::
299604dd 91Verbose execution. With this option *mkswap* will output more details about detected problems during swap area set up.
c6a568fc 92
2b2d3172 93include::man-common/help-version.adoc[]
c6a568fc
MB
94
95== ENVIRONMENT
96
97LIBBLKID_DEBUG=all::
299604dd 98enables libblkid debug output.
c6a568fc
MB
99
100LOCK_BLOCK_DEVICE=<mode>::
299604dd 101use exclusive BSD lock. The mode is "1" or "0". See *--lock* for more details.
c6a568fc
MB
102
103== NOTES
104
105The maximum useful size of a swap area depends on the architecture and the kernel version.
106
107The 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.
108
109Presently, Linux allows 32 swap areas. The areas in use can be seen in the file _/proc/swaps_.
110
111*mkswap* refuses areas smaller than 10 pages.
112
7167a454 113If you don't know the page size that your machine uses, you can look it up with *getconf PAGESIZE*.
c6a568fc
MB
114
115To set up a swap file, it is necessary to create that file before initializing it with *mkswap*, e.g. using a command like
116
117....
118# dd if=/dev/zero of=swapfile bs=1MiB count=$((8*1024))
119....
120
121to create 8GiB swapfile.
122
123Please read notes from *swapon*(8) about *the swap file use restrictions* (holes, preallocation and copy-on-write issues).
124
125== SEE ALSO
126
127*fdisk*(8),
128*swapon*(8)
129
625e9c61 130include::man-common/bugreports.adoc[]
c6a568fc 131
625e9c61 132include::man-common/footer.adoc[]
c6a568fc
MB
133
134ifdef::translation[]
625e9c61 135include::man-common/translation.adoc[]
c6a568fc 136endif::[]