1MKSWAP(8)                    System Administration                   MKSWAP(8)
2
3
4

NAME

6       mkswap - set up a Linux swap area
7

SYNOPSIS

9       mkswap [options] device [size]
10

DESCRIPTION

12       mkswap sets up a Linux swap area on a device or in a file.
13
14       The device argument will usually be a disk partition (something like
15       /dev/sdb7) but can also be a file. The Linux kernel does not look at
16       partition IDs, but many installation scripts will assume that
17       partitions of hex type 82 (LINUX_SWAP) are meant to be swap partitions.
18       (Warning: Solaris also uses this type. Be careful not to kill your
19       Solaris partitions.)
20
21       The size parameter is superfluous but retained for backwards
22       compatibility. (It specifies the desired size of the swap area in
23       1024-byte blocks. mkswap will use the entire partition or file if it is
24       omitted. Specifying it is unwise - a typo may destroy your disk.)
25
26       After creating the swap area, you need the swapon command to start
27       using it. Usually swap areas are listed in /etc/fstab so that they can
28       be taken into use at boot time by a swapon -a command in some boot
29       script.
30

WARNING

32       The swap header does not touch the first block. A boot loader or disk
33       label can be there, but it is not a recommended setup. The recommended
34       setup is to use a separate partition for a Linux swap area.
35
36       mkswap, like many others mkfs-like utils, erases the first partition
37       block to make any previous filesystem invisible.
38
39       However, mkswap refuses to erase the first block on a device with a
40       disk label (SUN, BSD, ...).
41

OPTIONS

43       -c, --check
44           Check the device (if it is a block device) for bad blocks before
45           creating the swap area. If any bad blocks are found, the count is
46           printed.
47
48       -f, --force
49           Go ahead even if the command is stupid. This allows the creation of
50           a swap area larger than the file or partition it resides on.
51
52           Also, without this option, mkswap will refuse to erase the first
53           block on a device with a partition table.
54
55       -L, --label label
56           Specify a label for the device, to allow swapon by label.
57
58       --lock[=mode]
59           Use exclusive BSD lock for device or file it operates. The optional
60           argument mode can be yes, no (or 1 and 0) or nonblock. If the mode
61           argument is omitted, it defaults to "yes". This option overwrites
62           environment variable $LOCK_BLOCK_DEVICE. The default is not to use
63           any lock at all, but it’s recommended to avoid collisions with
64           udevd or other tools.
65
66       -p, --pagesize size
67           Specify the page size (in bytes) to use. This option is usually
68           unnecessary; mkswap reads the size from the kernel.
69
70       -U, --uuid UUID
71           Specify the UUID to use. The default is to generate a UUID.
72
73       -v, --swapversion 1
74           Specify the swap-space version. (This option is currently
75           pointless, as the old -v 0 option has become obsolete and now only
76           -v 1 is supported. The kernel has not supported v0 swap-space
77           format since 2.5.22 (June 2002). The new version v1 is supported
78           since 2.1.117 (August 1998).)
79
80       --verbose
81           Verbose execution. With this option mkswap will output more details
82           about detected problems during swap area set up.
83
84       -h, --help
85           Display help text and exit.
86
87       -V, --version
88           Display version information and exit.
89

ENVIRONMENT

91       LIBBLKID_DEBUG=all
92           enables libblkid debug output.
93
94       LOCK_BLOCK_DEVICE=<mode>
95           use exclusive BSD lock. The mode is "1" or "0". See --lock for more
96           details.
97

NOTES

99       The maximum useful size of a swap area depends on the architecture and
100       the kernel version.
101
102       The maximum number of the pages that is possible to address by swap
103       area header is 4294967295 (32-bit unsigned int). The remaining space on
104       the swap device is ignored.
105
106       Presently, Linux allows 32 swap areas. The areas in use can be seen in
107       the file /proc/swaps.
108
109       mkswap refuses areas smaller than 10 pages.
110
111       If you don’t know the page size that your machine uses, you may be able
112       to look it up with cat /proc/cpuinfo (or you may not - the contents of
113       this file depend on architecture and kernel version).
114
115       To set up a swap file, it is necessary to create that file before
116       initializing it with mkswap, e.g. using a command like
117
118           # dd if=/dev/zero of=swapfile bs=1MiB count=$((8*1024))
119
120       to create 8GiB swapfile.
121
122       Please read notes from swapon(8) about the swap file use restrictions
123       (holes, preallocation and copy-on-write issues).
124

SEE ALSO

126       fdisk(8), swapon(8)
127

REPORTING BUGS

129       For bug reports, use the issue tracker at
130       https://github.com/karelzak/util-linux/issues.
131

AVAILABILITY

133       The mkswap command is part of the util-linux package which can be
134       downloaded from Linux Kernel Archive
135       <https://www.kernel.org/pub/linux/utils/util-linux/>.
136
137
138
139util-linux 2.37.2                 2021-06-02                         MKSWAP(8)
Impressum