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