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