blob: f507f63b9a09f6dcd09ba6e262573f55cdbeeda2 [file] [log] [blame]
Theodore Ts'o3839e651997-04-26 13:21:57 +00001.\" -*- nroff -*-
Theodore Ts'o74becf31997-04-26 14:37:06 +00002.TH BADBLOCKS 8 "@E2FSPROGS_MONTH@ @E2FSPROGS_YEAR@" "E2fsprogs version @E2FSPROGS_VERSION@"
Theodore Ts'o3839e651997-04-26 13:21:57 +00003.SH NAME
4badblocks \- search a device for bad blocks
5.SH SYNOPSIS
6.B badblocks
7[
JP Abgralle0ed7402014-03-19 19:08:39 -07008.B \-svwnfBX
Theodore Ts'odd018f52000-02-06 23:57:07 +00009]
10[
Theodore Ts'o3839e651997-04-26 13:21:57 +000011.B \-b
Theodore Ts'ocaf8ce41999-10-21 19:56:34 +000012.I block-size
Theodore Ts'o3839e651997-04-26 13:21:57 +000013]
14[
Theodore Ts'odd018f52000-02-06 23:57:07 +000015.B \-c
16.I blocks_at_once
17]
18[
Iustin Pop931b0282008-06-11 13:12:17 +020019.B \-e
20.I max_bad_blocks
21]
22[
Iustin Pop264f64a2008-06-12 09:30:04 +020023.B \-d
24.I read_delay_factor
25]
26[
Theodore Ts'odd018f52000-02-06 23:57:07 +000027.B \-i
28.I input_file
29]
30[
Theodore Ts'o3839e651997-04-26 13:21:57 +000031.B \-o
Theodore Ts'ocaf8ce41999-10-21 19:56:34 +000032.I output_file
Theodore Ts'o3839e651997-04-26 13:21:57 +000033]
34[
Theodore Ts'odd018f52000-02-06 23:57:07 +000035.B \-p
36.I num_passes
Theodore Ts'o3839e651997-04-26 13:21:57 +000037]
Theodore Ts'o849b6bc2003-05-07 09:52:14 -040038[
39.B \-t
40.I test_pattern
41]
Theodore Ts'ocaf8ce41999-10-21 19:56:34 +000042.I device
Theodore Ts'o35964b52000-07-06 13:19:43 +000043[
Theodore Ts'ocd130a02001-05-05 05:43:23 +000044.I last-block
Theodore Ts'o35964b52000-07-06 13:19:43 +000045] [
Theodore Ts'of56f32b2008-07-10 10:08:40 -040046.I first-block
Theodore Ts'o35964b52000-07-06 13:19:43 +000047]
Theodore Ts'o3839e651997-04-26 13:21:57 +000048.SH DESCRIPTION
49.B badblocks
50is used to search for bad blocks on a device (usually a disk partition).
Theodore Ts'o3839e651997-04-26 13:21:57 +000051.I device
Theodore Ts'ocaf8ce41999-10-21 19:56:34 +000052is the special file corresponding to the device (e.g
53.IR /dev/hdc1 ).
Theodore Ts'ocd130a02001-05-05 05:43:23 +000054.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.
Theodore Ts'of56f32b2008-07-10 10:08:40 -040057.I first-block
Theodore Ts'ocd130a02001-05-05 05:43:23 +000058is 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.
Theodore Ts'o3ed57c22001-12-24 15:01:59 -050061.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,
Theodore Ts'o19445ef2003-01-29 21:04:52 -050070since the block numbers which are generated are very dependent on the
Theodore Ts'odf95e092004-09-28 10:30:27 -040071block size in use by the filesystem.
72For this reason, it is strongly recommended that
Theodore Ts'o3ed57c22001-12-24 15:01:59 -050073users
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.
Theodore Ts'o3839e651997-04-26 13:21:57 +000084.SH OPTIONS
85.TP
Theodore Ts'ocaf8ce41999-10-21 19:56:34 +000086.BI \-b " block-size"
Theodore Ts'odf95e092004-09-28 10:30:27 -040087Specify the size of blocks in bytes. The default is 1024.
Theodore Ts'o3839e651997-04-26 13:21:57 +000088.TP
Theodore Ts'odd018f52000-02-06 23:57:07 +000089.BI \-c " number of blocks"
Theodore Ts'o167af992004-02-28 08:20:41 -050090is the number of blocks which are tested at a time. The default is 64.
Theodore Ts'odd018f52000-02-06 23:57:07 +000091.TP
Iustin Pop931b0282008-06-11 13:12:17 +020092.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
Iustin Pop264f64a2008-06-12 09:30:04 +020097.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
Theodore Ts'o981dc562000-07-06 14:13:29 +0000105.B \-f
106Normally, badblocks will refuse to do a read/write or a non-destructive
Theodore Ts'o541d1732002-02-23 21:23:26 -0500107test on a device which is mounted, since either can cause the system to
Theodore Ts'oa1411352002-08-17 17:39:39 -0400108potentially crash and/or damage the filesystem even if it is mounted
Theodore Ts'o81393672005-04-16 14:05:09 -0400109read-only. This can be overridden using the
Theodore Ts'o541d1732002-02-23 21:23:26 -0500110.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.
Theodore Ts'o981dc562000-07-06 14:13:29 +0000117.TP
Theodore Ts'odd018f52000-02-06 23:57:07 +0000118.BI \-i " input_file"
Theodore Ts'o4d003982000-04-03 16:01:11 +0000119Read 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.
Theodore Ts'odd018f52000-02-06 23:57:07 +0000133.TP
Theodore Ts'o4001b8a2009-06-29 01:03:27 -0400134.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
Theodore Ts'ocaf8ce41999-10-21 19:56:34 +0000140.BI \-o " output_file"
Theodore Ts'odd018f52000-02-06 23:57:07 +0000141Write the list of bad blocks to the specified file. Without this option,
Theodore Ts'o3839e651997-04-26 13:21:57 +0000142.B badblocks
Theodore Ts'o92bcc591998-02-16 22:29:34 +0000143displays the list on its standard output. The format of this file is suitable
Theodore Ts'ocaf8ce41999-10-21 19:56:34 +0000144for use by the
Theodore Ts'odd018f52000-02-06 23:57:07 +0000145.
Theodore Ts'ocaf8ce41999-10-21 19:56:34 +0000146.B \-l
147option in
Theodore Ts'o92bcc591998-02-16 22:29:34 +0000148.BR e2fsck (8)
149or
150.BR mke2fs (8).
Theodore Ts'o3839e651997-04-26 13:21:57 +0000151.TP
Theodore Ts'odd018f52000-02-06 23:57:07 +0000152.BI \-p " num_passes"
Theodore Ts'o4d003982000-04-03 16:01:11 +0000153Repeat 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.
Theodore Ts'odd018f52000-02-06 23:57:07 +0000158.TP
Theodore Ts'o4001b8a2009-06-29 01:03:27 -0400159.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
Theodore Ts'o849b6bc2003-05-07 09:52:14 -0400168.BI \-t " test_pattern"
Theodore Ts'o84c05452003-05-18 01:11:52 -0400169Specify 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.
Theodore Ts'o849b6bc2003-05-07 09:52:14 -0400174For read/write (\fB-w\fR) and non-destructive (\fB-n\fR) modes,
Theodore Ts'o81393672005-04-16 14:05:09 -0400175one or more test patterns may be specified by specifying the
Theodore Ts'o84c05452003-05-18 01:11:52 -0400176.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
Theodore Ts'o849b6bc2003-05-07 09:52:14 -0400181numbers of blocks will fail verification.
182If multiple patterns
Theodore Ts'od3cb5e52006-03-27 12:16:30 -0500183are specified then all blocks will be tested with one pattern
Theodore Ts'o849b6bc2003-05-07 09:52:14 -0400184before proceeding to the next pattern.
185.TP
Theodore Ts'ocaf8ce41999-10-21 19:56:34 +0000186.B \-v
JP Abgralle0ed7402014-03-19 19:08:39 -0700187Verbose mode. Will write the number of read errors, write errors and data-
188corruptions to stderr.
Theodore Ts'o3839e651997-04-26 13:21:57 +0000189.TP
Theodore Ts'ocaf8ce41999-10-21 19:56:34 +0000190.B \-w
Theodore Ts'o3839e651997-04-26 13:21:57 +0000191Use write-mode test. With this option,
192.B badblocks
193scans for bad blocks by writing some patterns (0xaa, 0x55, 0xff, 0x00) on
Theodore Ts'oa551b782000-07-13 22:05:31 +0000194every block of the device, reading every block and comparing the contents.
Theodore Ts'o177a9ac2001-08-30 18:07:40 -0400195This option may not be combined with the
Theodore Ts'oa551b782000-07-13 22:05:31 +0000196.B \-n
197option, as they are mutually exclusive.
Theodore Ts'o52a07932007-04-02 18:42:59 -0400198.TP
JP Abgralle0ed7402014-03-19 19:08:39 -0700199.B \-B
200Use buffered I/O and do not use Direct I/O, even if it is available.
201.TP
Theodore Ts'o52a07932007-04-02 18:42:59 -0400202.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.
Theodore Ts'o3839e651997-04-26 13:21:57 +0000208.SH WARNING
Theodore Ts'ocaf8ce41999-10-21 19:56:34 +0000209Never use the
210.B \-w
Theodore Ts'od3cb5e52006-03-27 12:16:30 -0500211option on a device containing an existing file system.
Theodore Ts'o4d003982000-04-03 16:01:11 +0000212This option erases data! If you want to do write-mode testing on
213an existing file system, use the
214.B \-n
Theodore Ts'oa551b782000-07-13 22:05:31 +0000215option instead. It is slower, but it will preserve your data.
Iustin Pop931b0282008-06-11 13:12:17 +0200216.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.
Theodore Ts'o3839e651997-04-26 13:21:57 +0000223.SH AUTHOR
224.B badblocks
Theodore Ts'offe4cab2000-04-03 13:27:41 +0000225was written by Remy Card <Remy.Card@linux.org>. Current maintainer is
226Theodore Ts'o <tytso@alum.mit.edu>. Non-destructive read/write test
Theodore Ts'o4d003982000-04-03 16:01:11 +0000227implemented by David Beattie <dbeattie@softhome.net>.
Theodore Ts'o3839e651997-04-26 13:21:57 +0000228.SH AVAILABILITY
229.B badblocks
Theodore Ts'o12da49c2001-05-12 15:49:17 +0000230is part of the e2fsprogs package and is available from
Theodore Ts'o348e43d2001-05-03 14:43:43 +0000231http://e2fsprogs.sourceforge.net.
Theodore Ts'o3839e651997-04-26 13:21:57 +0000232.SH SEE ALSO
233.BR e2fsck (8),
234.BR mke2fs (8)