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