1BADBLOCKS(8) System Manager's Manual BADBLOCKS(8)
2
3
4
6 badblocks - search a device for bad blocks
7
9 badblocks [ -svwnf ] [ -b block-size ] [ -c blocks_at_once ] [ -i
10 input_file ] [ -o output_file ] [ -p num_passes ] [ -t test_pattern ]
11 device [ last-block ] [ start-block ]
12
14 badblocks is used to search for bad blocks on a device (usually a disk
15 partition). device is the special file corresponding to the device
16 (e.g /dev/hdc1). last-block is the last block to be checked; if it is
17 not specified, the last block on the device is used as a default.
18 start-block is an optional parameter specifying the starting block num‐
19 ber for the test, which allows the testing to start in the middle of
20 the disk. If it is not specified the first block on the disk is used
21 as a default.
22
23 Important note: If the output of badblocks is going to be fed to the
24 e2fsck or mke2fs programs, it is important that the block size is prop‐
25 erly specified, since the block numbers which are generated are very
26 dependent on the block size in use by the filesystem. For this reason,
27 it is strongly recommended that users not run badblocks directly, but
28 rather use the -c option of the e2fsck and mke2fs programs.
29
31 -b block-size
32 Specify the size of blocks in bytes. The default is 1024.
33
34 -c number of blocks
35 is the number of blocks which are tested at a time. The default
36 is 64.
37
38 -f Normally, badblocks will refuse to do a read/write or a non-
39 destructive test on a device which is mounted, since either can
40 cause the system to potentially crash and/or damage the filesys‐
41 tem even if it is mounted read-only. This can be overridden
42 using the -f flag, but should almost never be used --- if you
43 think you're smarter than the badblocks program, you almost cer‐
44 tainly aren't. The only time when this option might be safe to
45 use is if the /etc/mtab file is incorrect, and the device really
46 isn't mounted.
47
48 -i input_file
49 Read a list of already existing known bad blocks. Badblocks
50 will skip testing these blocks since they are known to be bad.
51 If input_file is specified as "-", the list will be read from
52 the standard input. Blocks listed in this list will be omitted
53 from the list of new bad blocks produced on the standard output
54 or in the output file. The -b option of dumpe2fs(8) can be used
55 to retrieve the list of blocks currently marked bad on an exist‐
56 ing filesystem, in a format suitable for use with this option.
57
58 -o output_file
59 Write the list of bad blocks to the specified file. Without
60 this option, badblocks displays the list on its standard output.
61 The format of this file is suitable for use by the -l option in
62 e2fsck(8) or mke2fs(8).
63
64 -p num_passes
65 Repeat scanning the disk until there are no new blocks discov‐
66 ered in num_passes consecutive scans of the disk. Default is 0,
67 meaning badblocks will exit after the first pass.
68
69 -t test_pattern
70 Specify a test pattern to be read (and written) to disk blocks.
71 The test_pattern may either be a numeric value between 0 and
72 ULONG_MAX-1 inclusive, or the word "random", which specifies
73 that the block should be filled with a random bit pattern. For
74 read/write (-w) and non-destructive (-n) modes, one or more test
75 patterns may be specified by specifying the -t option for each
76 test pattern desired. For read-only mode only a single pattern
77 may be specified and it may not be "random". Read-only testing
78 with a pattern assumes that the specified pattern has previously
79 been written to the disk - if not, large numbers of blocks will
80 fail verification. If multiple patterns are specified then all
81 blocks will be tested with one pattern before proceeding to the
82 next pattern.
83
84 -n Use non-destructive read-write mode. By default only a non-
85 destructive read-only test is done. This option must not be
86 combined with the -w option, as they are mutually exclusive.
87
88 -s Show the progress of the scan by writing out the block numbers
89 as they are checked.
90
91 -v Verbose mode.
92
93 -w Use write-mode test. With this option, badblocks scans for bad
94 blocks by writing some patterns (0xaa, 0x55, 0xff, 0x00) on
95 every block of the device, reading every block and comparing the
96 contents. This option may not be combined with the -n option,
97 as they are mutually exclusive.
98
99 -X Internal flag only to be used by e2fsck(8) and mke2fs(8). It
100 bypasses the exclusive mode in-use device safety check.
101
103 Never use the -w option on a device containing an existing file system.
104 This option erases data! If you want to do write-mode testing on an
105 existing file system, use the -n option instead. It is slower, but it
106 will preserve your data.
107
109 badblocks was written by Remy Card <Remy.Card@linux.org>. Current
110 maintainer is Theodore Ts'o <tytso@alum.mit.edu>. Non-destructive
111 read/write test implemented by David Beattie <dbeattie@softhome.net>.
112
114 badblocks is part of the e2fsprogs package and is available from
115 http://e2fsprogs.sourceforge.net.
116
118 e2fsck(8), mke2fs(8)
119
120
121
122E2fsprogs version 1.40.2 July 2007 BADBLOCKS(8)