Imported upstream version 1.5
[manpages-zh.git] / raw / man8 / badblocks.8
blobc33d3d819d92988ec659823305a4850ef10ca98f
1 .\" -*- nroff -*-
2 .TH BADBLOCKS 8 "July 2003" "E2fsprogs version 1.34"
3 .SH NAME
4 badblocks \- search a device for bad blocks
5 .SH SYNOPSIS
6 .B badblocks
8 .B \-svwnf
11 .B \-b
12 .I block-size
15 .B \-c
16 .I blocks_at_once
19 .B \-i
20 .I input_file
23 .B \-o
24 .I output_file
27 .B \-p
28 .I num_passes
31 .B \-t
32 .I test_pattern
34 .I device
36 .I last-block
37 ] [
38 .I start-block 
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.   For this reason, it is strongly recommended that
64 users 
65 .B not
66 run 
67 .B badblocks 
68 directly, but rather use the 
69 .B \-c
70 option of the
71 .B e2fsck
72 and 
73 .B mke2fs
74 programs.
75 .SH OPTIONS
76 .TP
77 .BI \-b " block-size"
78 Specify the size of blocks in bytes.
79 .TP
80 .BI \-c " number of blocks"
81 is the number of blocks which are tested at a time.  The default is 16.
82 Increasing this number will increase the efficiency of
83 .B badblocks
84 but also will increase its memory usage.
85 .B Badblocks
86 needs memory proportional to the number of blocks tested at once, in
87 read-only mode, proportional to twice that number in read-write mode,
88 and proportional to three times that number in non-destructive read-write
89 mode.  If you set the number-of-blocks parameter to too high a value,
90 .B badblocks
91 will exit almost immediately with an out-of-memory error "while allocating
92 buffers".  If you set it too low, however, for a non-destructive-write-mode
93 test, then it's possble for questionable blocks on an unreliable
94 hard drive to be hidden by the effects of the hard disk track buffer.
95 .TP
96 .B \-f
97 Normally, badblocks will refuse to do a read/write or a non-destructive
98 test on a device which is mounted, since either can cause the system to
99 potentially crash and/or damage the filesystem even if it is mounted
100 read-only.  This can be overriden using the
101 .B \-f
102 flag, but should almost never be used --- if you think you're smarter
103 than the 
104 .B badblocks
105 program, you almost certainly aren't.  The only time when this option 
106 might be safe to use is if the /etc/mtab file is incorrect, and the device
107 really isn't mounted.
109 .BI \-i " input_file"
110 Read a list of already existing known bad blocks.
111 .B Badblocks
112 will skip testing these blocks since they are known to be bad.  If
113 .I input_file
114 is specified as "-", the list will be read from the standard input.
115 Blocks listed in this list will be omitted from the list of
116 .I new
117 bad blocks produced on the standard output or in the output file.
119 .B \-b
120 option of
121 .BR dumpe2fs (8)
122 can be used to retrieve the list of blocks currently marked bad on
123 an existing filesystem, in a format suitable for use with this option.
125 .BI \-o " output_file"
126 Write the list of bad blocks to the specified file.  Without this option,
127 .B badblocks
128 displays the list on its standard output.  The format of this file is suitable
129 for use by the
131 .B \-l
132 option in 
133 .BR e2fsck (8)
135 .BR mke2fs (8).
137 .BI \-p " num_passes"
138 Repeat scanning the disk until there are no new blocks discovered in
139 num_passes consecutive scans of the disk.
140 Default is 0, meaning
141 .B badblocks
142 will exit after the first pass.
144 .BI \-t " test_pattern"
145 Specify a test pattern to be read (and written) to disk blocks.   The
146 .I test_pattern
147 may either be a numeric value between 0 and ULONG_MAX-1 inclusive, or the word 
148 "random", which specifies that the block should be filled with a random
149 bit pattern.
150 For read/write (\fB-w\fR) and non-destructive (\fB-n\fR) modes,
151 one or more test patterns may be specified by specifiying the
152 .B -t
153 option for each test pattern desired.  For
154 read-only mode only a single pattern may be specified and it may not be
155 "random".  Read-only testing with a pattern assumes that the
156 specified pattern has previously been written to the disk - if not, large
157 numbers of blocks will fail verification.  
158 If multiple patterns
159 are specified then all blocks will be tested with an one pattern 
160 before proceeding to the next pattern.
162 .B \-n
163 Use non-destructive read-write mode.  By default only a non-destructive 
164 read-only test is done.  This option must not be combined with the 
165 .B \-w
166 option, as they are mutually exclusive.
168 .B \-s
169 Show the progress of the scan by writing out the block numbers as they
170 are checked.
172 .B \-v
173 Verbose mode.
175 .B \-w
176 Use write-mode test. With this option,
177 .B badblocks
178 scans for bad blocks by writing some patterns (0xaa, 0x55, 0xff, 0x00) on
179 every block of the device, reading every block and comparing the contents.  
180 This option may not be combined with the 
181 .B \-n 
182 option, as they are mutually exclusive.
183 .SH WARNING
184 Never use the
185 .B \-w
186 option on an device containing an existing file system.
187 This option erases data!  If you want to do write-mode testing on
188 an existing file system, use the
189 .B \-n
190 option instead.  It is slower, but it will preserve your data.  
191 .SH AUTHOR
192 .B badblocks
193 was written by Remy Card <Remy.Card@linux.org>.  Current maintainer is
194 Theodore Ts'o <tytso@alum.mit.edu>.  Non-destructive read/write test
195 implemented by David Beattie <dbeattie@softhome.net>.
196 .SH AVAILABILITY
197 .B badblocks
198 is part of the e2fsprogs package and is available from 
199 http://e2fsprogs.sourceforge.net.
200 .SH SEE ALSO
201 .BR e2fsck (8),
202 .BR mke2fs (8)