Whamcloud - gitweb
Change "filesystem" to "file system" in the man pages
[tools/e2fsprogs.git] / misc / badblocks.8.in
1 .\" -*- nroff -*-
2 .TH BADBLOCKS 8 "@E2FSPROGS_MONTH@ @E2FSPROGS_YEAR@" "E2fsprogs version @E2FSPROGS_VERSION@"
3 .SH NAME
4 badblocks \- search a device for bad blocks
5 .SH SYNOPSIS
6 .B badblocks
7 [
8 .B \-svwnfBX
9 ]
10 [
11 .B \-b
12 .I block_size
13 ]
14 [
15 .B \-c
16 .I blocks_at_once
17 ]
18 [
19 .B \-d
20 .I read_delay_factor
21 ]
22 [
23 .B \-e
24 .I max_bad_blocks
25 ]
26 [
27 .B \-i
28 .I input_file
29 ]
30 [
31 .B \-o
32 .I output_file
33 ]
34 [
35 .B \-p
36 .I num_passes
37 ]
38 [
39 .B \-t
40 .I test_pattern
41 ]
42 .I device
43 [
44 .I last_block
45 ] [
46 .I first_block
47 ]
48 .SH DESCRIPTION
49 .B badblocks
50 is used to search for bad blocks on a device (usually a disk partition).
51 .I device
52 is the special file corresponding to the device (e.g
53 .IR /dev/hdc1 ).
54 .I last_block
55 is the last block to be checked; if it is not specified, the last block
56 on the device is used as a default.
57 .I first_block
58 is an optional parameter specifying the starting block number
59 for the test, which allows the testing to start in the middle of the
60 disk.  If it is not specified the first block on the disk is used as a default.
61 .PP
62 .B Important note:
63 If the output of
64 .B badblocks
65 is going to be fed to the
66 .B e2fsck
67 or
68 .B mke2fs
69 programs, it is important that the block size is properly specified,
70 since the block numbers which are generated are very dependent on the
71 block size in use by the file system.
72 For this reason, it is strongly recommended that
73 users
74 .B not
75 run
76 .B badblocks
77 directly, but rather use the
78 .B \-c
79 option of the
80 .B e2fsck
81 and
82 .B mke2fs
83 programs.
84 .SH OPTIONS
85 .TP
86 .BI \-b " block_size"
87 Specify the size of blocks in bytes.  The default is 1024.
88 .TP
89 .BI \-c " number of blocks"
90 is the number of blocks which are tested at a time.  The default is 64.
91 .TP
92 .BI \-d " read delay factor"
93 This parameter, if passed and non-zero, will cause bad blocks to sleep
94 between reads if there were no errors encountered in the read
95 operation; the delay will be calculated as a percentage of the time it
96 took for the read operation to be performed. In other words, a value of
97 100 will cause each read to be delayed by the amount the previous read
98 took, and a value of 200 by twice the amount.
99 .TP
100 .BI \-e " max bad block count"
101 Specify a maximum number of bad blocks before aborting the test.  The
102 default is 0, meaning the test will continue until the end of the test
103 range is reached.
104 .TP
105 .B \-f
106 Normally, badblocks will refuse to do a read/write or a non-destructive
107 test on a device which is mounted, since either can cause the system to
108 potentially crash and/or damage the file system even if it is mounted
109 read-only.  This can be overridden using the
110 .B \-f
111 flag, but should almost never be used --- if you think you're smarter
112 than the
113 .B badblocks
114 program, you almost certainly aren't.  The only time when this option
115 might be safe to use is if the /etc/mtab file is incorrect, and the device
116 really isn't mounted.
117 .TP
118 .BI \-i " input_file"
119 Read a list of already existing known bad blocks.
120 .B Badblocks
121 will skip testing these blocks since they are known to be bad.  If
122 .I input_file
123 is specified as "-", the list will be read from the standard input.
124 Blocks listed in this list will be omitted from the list of
125 .I new
126 bad blocks produced on the standard output or in the output file.
127 The
128 .B \-b
129 option of
130 .BR dumpe2fs (8)
131 can be used to retrieve the list of blocks currently marked bad on
132 an existing file system, in a format suitable for use with this option.
133 .TP
134 .B \-n
135 Use non-destructive read-write mode.  By default only a non-destructive
136 read-only test is done.  This option must not be combined with the
137 .B \-w
138 option, as they are mutually exclusive.
139 .TP
140 .BI \-o " output_file"
141 Write the list of bad blocks to the specified file.  Without this option,
142 .B badblocks
143 displays the list on its standard output.  The format of this file is suitable
144 for use by the
145 .
146 .B \-l
147 option in
148 .BR e2fsck (8)
149 or
150 .BR mke2fs (8).
151 .TP
152 .BI \-p " num_passes"
153 Repeat scanning the disk until there are no new blocks discovered in
154 num_passes consecutive scans of the disk.
155 Default is 0, meaning
156 .B badblocks
157 will exit after the first pass.
158 .TP
159 .B \-s
160 Show the progress of the scan by writing out rough percentage completion
161 of the current badblocks pass over the disk.  Note that badblocks may do
162 multiple test passes over the disk, in particular if the
163 .B \-p
164 or
165 .B \-w
166 option is requested by the user.
167 .TP
168 .BI \-t " test_pattern"
169 Specify a test pattern to be read (and written) to disk blocks.   The
170 .I test_pattern
171 may either be a numeric value between 0 and ULONG_MAX-1 inclusive, or the word
172 "random", which specifies that the block should be filled with a random
173 bit pattern.
174 For read/write (\fB-w\fR) and non-destructive (\fB-n\fR) modes,
175 one or more test patterns may be specified by specifying the
176 .B -t
177 option for each test pattern desired.  For
178 read-only mode only a single pattern may be specified and it may not be
179 "random".  Read-only testing with a pattern assumes that the
180 specified pattern has previously been written to the disk - if not, large
181 numbers of blocks will fail verification.
182 If multiple patterns
183 are specified then all blocks will be tested with one pattern
184 before proceeding to the next pattern.
185 .TP
186 .B \-v
187 Verbose mode.  Will write the number of read errors, write errors and data-
188 corruptions to stderr.
189 .TP
190 .B \-w
191 Use write-mode test. With this option,
192 .B badblocks
193 scans for bad blocks by writing some patterns (0xaa, 0x55, 0xff, 0x00) on
194 every block of the device, reading every block and comparing the contents.
195 This option may not be combined with the
196 .B \-n
197 option, as they are mutually exclusive.
198 .TP
199 .B \-B
200 Use buffered I/O and do not use Direct I/O, even if it is available.
201 .TP
202 .B \-X
203 Internal flag only to be used by
204 .BR e2fsck (8)
205 and
206 .BR mke2fs (8).
207 It bypasses the exclusive mode in-use device safety check.
208 .SH WARNING
209 Never use the
210 .B \-w
211 option on a device containing an existing file system.
212 This option erases data!  If you want to do write-mode testing on
213 an existing file system, use the
214 .B \-n
215 option instead.  It is slower, but it will preserve your data.
216 .PP
217 The
218 .B \-e
219 option will cause badblocks to output a possibly incomplete list of
220 bad blocks. Therefore it is recommended to use it only when one wants
221 to know if there are any bad blocks at all on the device, and not when
222 the list of bad blocks is wanted.
223 .SH AUTHOR
224 .B badblocks
225 was written by Remy Card <Remy.Card@linux.org>.  Current maintainer is
226 Theodore Ts'o <tytso@alum.mit.edu>.  Non-destructive read/write test
227 implemented by David Beattie <dbeattie@softhome.net>.
228 .SH AVAILABILITY
229 .B badblocks
230 is part of the e2fsprogs package and is available from
231 http://e2fsprogs.sourceforge.net.
232 .SH SEE ALSO
233 .BR e2fsck (8),
234 .BR mke2fs (8)