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