]> git.ipfire.org Git - thirdparty/util-linux.git/blob - historic/mkswap.8
Imported from util-linux-2.5 tarball.
[thirdparty/util-linux.git] / historic / mkswap.8
1 .\" Copyright 1992, 1993 Rickard E. Faith (faith@cs.unc.edu)
2 .\" May be distributed under the GNU General Public License
3 .\" Modified with suggestions from Linus, Mon Feb 1 21:40:49 1993
4 .\" Modified with patches from Kai, Wed Jun 22 21:54:56 1994
5 .\" Patches from jaggy@purplet.demon.co.uk (Mike Jagdis), Wed Feb 8 1995
6 .\" Added comments from Nick Holloway, Sat Feb 11 1995, faith@cs.unc.edu
7 .\" "
8 .TH MKSWAP 8 "8 February 1995" "Linux 1.0" "Linux Programmer's Manual"
9 .SH NAME
10 mkswap \- set up a Linux swap device
11 .SH SYNOPSIS
12 .B "mkswap [ \-c ]"
13 .IB device " [" size-in-blocks "]"
14 .SH DESCRIPTION
15 .B mkswap
16 sets up a Linux swap area on a device (usually a disk partition).
17
18 The
19 .I device
20 is usually of the following form:
21
22 .nf
23 .RS
24 /dev/hda[1-8]
25 /dev/hdb[1-8]
26 /dev/sda[1-8]
27 /dev/sdb[1-8]
28 .RE
29 .fi
30
31 The
32 .I size-in-blocks
33 parameter is the desired size of the file system, in blocks. This
34 information is determined automatically by mkswap if it is omitted. Block
35 counts are rounded down to pages of 4 kB each. Only block counts equal to
36 or greater than 40 and equal to or less than 131072 are allowed. Block
37 counts greater than 130752 are (silently) rounded down to 130752.
38
39 As Nick Holloway explains, the actual maximum for each swap file/partition
40 is:
41 .RS
42 (4096 - 10) * 8 * 4096 = 133890048 bytes = 130752 blocks = 127.6875 Mb
43 .RE
44 This is because a single page is used to hold the swap bitmap at the
45 start of the partition, where each bit is a single 4K page. The reason
46 for the -10, is that the signature is "SWAP-SPACE" -- 10 characters.
47
48 .B mkswap
49 can also set up swap files, although the file has to be created first. A
50 sequence of commands similar to the following is reasonable for this
51 purpose:
52
53 .nf
54 .RS
55 # dd if=/dev/zero of=swapfile bs=1024 count=8192
56 # mkswap swapfile 8192
57 # sync
58 # swapon swapfile
59 .RE
60 .fi
61
62 Note that the regular file has to be created before running
63 .B mkswap
64 on the file, and that the file must not contain any holes (so, using
65 .BR cp (1)
66 to create the file is not acceptable).
67
68 .SH OPTIONS
69 .TP
70 .B \-c
71 Check the device for bad blocks before creating the file system. If any
72 are found, the count is printed. This option is meant to be used for swap
73 partitions
74 .BR only ,
75 and should
76 .B not
77 be used for regular files! To make sure that regular files do not contain
78 bad blocks, the partition that contains the regular file should have been
79 created with
80 .BR "mkfs -c" .
81 .SH "SEE ALSO"
82 .BR fsck (8),
83 .BR mkfs (8),
84 .BR fdisk (8)
85 .SH AUTHOR
86 Linus Torvalds (torvalds@cs.helsinki.fi)