Upload Tizen:Base source
[framework/base/util-linux-ng.git] / disk-utils / mkswap.8
1 .\" Copyright 1998 Andries E. Brouwer (aeb@cwi.nl)
2 .\"
3 .\" May be distributed under the GNU General Public License
4 .\" Rewritten for 2.1.117, aeb, 981010.
5 .\"
6 .TH MKSWAP 8 "13 March 2009" "Linux" "Linux Programmer's Manual"
7 .SH NAME
8 mkswap \- set up a Linux swap area
9 .SH SYNOPSIS
10 .B mkswap
11 .RB [ \-c ]
12 .RB [ \-f ]
13 .RB [ \-p
14 .IR PSZ ]
15 .RB [ \-L
16 .IR label ]
17 .RB [ \-U
18 .IR uuid ]
19 .I device
20 .RI [ size ]
21 .SH DESCRIPTION
22 .B mkswap
23 sets up a Linux swap area on a device or in a file.
24
25 The
26 .I device
27 argument will usually be a disk partition (something like
28 .IR /dev/sdb7 )
29 but can also be a file.
30 The Linux kernel does not look at partition Id's, but
31 many installation scripts will assume that partitions
32 of hex type 82 (LINUX_SWAP) are meant to be swap partitions.
33 (\fBWarning: Solaris also uses this type. Be careful not to kill
34 your Solaris partitions.\fP)
35
36 The
37 .I size
38 parameter is superfluous but retained for backwards compatibility.
39 (It specifies the desired size of the swap area in 1024-byte blocks.
40 .B mkswap
41 will use the entire partition or file if it is omitted.
42 Specifying it is unwise - a typo may destroy your disk.)
43
44 The
45 .I PSZ
46 parameter specifies the page size to use. It is almost always
47 unnecessary (even unwise) to specify it, but certain old libc
48 versions lie about the page size, so it is possible that
49 .B mkswap
50 gets it wrong. The symptom is that a subsequent
51 .B swapon
52 fails because no swap signature is found. Typical values for
53 .I PSZ
54 are 4096 or 8192.
55
56 After creating the swap area, you need the
57 .B swapon
58 command to start using it. Usually swap areas are listed in
59 .I /etc/fstab
60 so that they can be taken into use at boot time by a
61 .B swapon -a
62 command in some boot script.
63
64 .SH WARNING
65 The swap header does not touch the first block. A boot loader or disk label
66 can be there, but it is not recommended setup. The recommended setup is to
67 use a separate partition for a Linux swap area.
68
69 .B mkswap like many others mkfs-like utils erases the first block to remove
70 .B old on-disk filesystems.
71
72 .B mkswap
73 refuses to erase the first block on a device with a disk
74 label (SUN, BSD, ...) or on whole disk (e.g. /dev/sda).
75
76 .SH OPTIONS
77 .TP
78 .B \-c
79 Check the device (if it is a block device) for bad blocks
80 before creating the swap area.
81 If any are found, the count is printed.
82 .TP
83 .B \-f
84 Force - go ahead even if the command is stupid.
85 This allows the creation of a swap area larger than the file
86 or partition it resides on.
87
88 Without this option
89 .B mkswap
90 will refuse to erase the first block on a device with a partition table or on
91 whole disk (e.g. /dec/sda).
92 .TP
93 .BI \-p \ PSZ
94 Specify the page size to use.
95 .TP
96 .BI \-L \ label
97 Specify a label, to allow swapon by label.
98 (Only for new style swap areas.)
99 .TP
100 .BR \-v0 , \ \-v1
101 Specify the swap space version. This option is deprecated and \-v1 is
102 supported only.
103
104 The kernel has not supported v0 swap space format since 2.5.22. The new version
105 v1 is supported since 2.1.117.
106
107 .TP
108 .BI \-U \ uuid
109 Specify the uuid to use. The default is to generate UUIDs.
110
111 .SH NOTES
112 The maximum useful size of a swap area depends on the architecture and
113 the kernel version.
114 It is roughly 2GiB on i386, PPC, m68k, ARM, 1GiB on sparc, 512MiB on mips,
115 128GiB on alpha and 3TiB on sparc64. For kernels after 2.3.3 there is no
116 such limitation.
117
118 Note that before 2.1.117 the kernel allocated one byte for each page,
119 while it now allocates two bytes, so that taking a swap area of 2 GiB
120 in use might require 2 MiB of kernel memory.
121
122 Presently, Linux allows 32 swap areas (this was 8 before Linux 2.4.10).
123 The areas in use can be seen in the file
124 .I /proc/swaps
125 (since 2.1.25).
126
127 .B mkswap
128 refuses areas smaller than 10 pages.
129
130 If you don't know the page size that your machine uses, you may be
131 able to look it up with "cat /proc/cpuinfo" (or you may not -
132 the contents of this file depend on architecture and kernel version).
133
134 To setup a swap file, it is necessary to create that file before
135 initializing it with
136 .BR mkswap ,
137 e.g. using a command like
138
139 .nf
140 .RS
141 # dd if=/dev/zero of=swapfile bs=1024 count=65536
142 .RE
143 .fi
144
145 Note that a swap file must not contain any holes (so, using
146 .BR cp (1)
147 to create the file is not acceptable).
148
149
150 .SH "SEE ALSO"
151 .BR fdisk (8),
152 .BR swapon (8)
153 .SH AVAILABILITY
154 The mkswap command is part of the util-linux-ng package and is available from
155 ftp://ftp.kernel.org/pub/linux/utils/util-linux-ng/.