Merge from vendor branch NTPD:
[dragonfly.git] / sbin / badsect / badsect.8
1 .\" Copyright (c) 1985, 1991, 1993
2 .\"     The Regents of the University of California.  All rights reserved.
3 .\"
4 .\" Redistribution and use in source and binary forms, with or without
5 .\" modification, are permitted provided that the following conditions
6 .\" are met:
7 .\" 1. Redistributions of source code must retain the above copyright
8 .\"    notice, this list of conditions and the following disclaimer.
9 .\" 2. Redistributions in binary form must reproduce the above copyright
10 .\"    notice, this list of conditions and the following disclaimer in the
11 .\"    documentation and/or other materials provided with the distribution.
12 .\" 3. All advertising materials mentioning features or use of this software
13 .\"    must display the following acknowledgment:
14 .\"     This product includes software developed by the University of
15 .\"     California, Berkeley and its contributors.
16 .\" 4. Neither the name of the University nor the names of its contributors
17 .\"    may be used to endorse or promote products derived from this software
18 .\"    without specific prior written permission.
19 .\"
20 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 .\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 .\" SUCH DAMAGE.
31 .\"
32 .\"     @(#)badsect.8   8.1 (Berkeley) 6/5/93
33 .\" $FreeBSD: src/sbin/badsect/badsect.8,v 1.10.2.6 2002/08/21 18:58:06 trhodes Exp $
34 .\" $DragonFly: src/sbin/badsect/badsect.8,v 1.2 2003/06/17 04:27:32 dillon Exp $
35 .\"
36 .Dd June 5, 1993
37 .Dt BADSECT 8
38 .Os
39 .Sh NAME
40 .Nm badsect
41 .Nd create files to contain bad sectors
42 .Sh SYNOPSIS
43 .Nm
44 .Ar bbdir sector ...
45 .Sh DESCRIPTION
46 The
47 .Nm
48 utility makes a file to contain a bad sector.  Normally, bad sectors
49 are made inaccessible by the standard formatter, which provides
50 a forwarding table for bad sectors to the driver.
51 If a driver supports the bad blocking standard it is much preferable to
52 use that method to isolate bad blocks, since the bad block forwarding
53 makes the pack appear perfect, and such packs can then be copied with
54 .Xr dd 1 .
55 The technique used by this program is also less general than
56 bad block forwarding, as
57 .Nm
58 can't make amends for
59 bad blocks in the i-list of file systems or in swap areas.
60 .Pp
61 On some disks,
62 adding a sector which is suddenly bad to the bad sector table
63 currently requires the running of the standard
64 .Tn DEC
65 formatter.
66 Thus to deal with a newly bad block
67 or on disks where the drivers
68 do not support the bad-blocking standard
69 .Nm
70 may be used to good effect.
71 .Pp
72 The
73 .Nm
74 utility is used on a quiet file system in the following way:
75 First mount the file system, and change to its root directory.
76 Make a directory
77 .Li BAD
78 there.
79 Run
80 .Nm
81 giving as argument the
82 .Ar BAD
83 directory followed by
84 all the bad sectors you wish to add.
85 (The sector numbers must be relative to the beginning of
86 the file system, but this is not hard as the system reports
87 relative sector numbers in its console error messages.)
88 Then change back to the root directory, unmount the file system
89 and run
90 .Xr fsck 8
91 on the file system.  The bad sectors should show up in two files
92 or in the bad sector files and the free list.  Have
93 .Xr fsck
94 remove files containing the offending bad sectors, but
95 .Em do not
96 have it remove the
97 .Pa BAD/ Ns Em nnnnn
98 files.
99 This will leave the bad sectors in only the
100 .Li BAD
101 files.
102 .Pp
103 The
104 .Nm
105 utility works by giving the specified sector numbers in a
106 .Xr mknod 2
107 system call,
108 creating an illegal file whose first block address is the block containing
109 bad sector and whose name is the bad sector number.
110 When it is discovered by
111 .Xr fsck 8
112 it will ask
113 .Dq Li "HOLD BAD BLOCK \&?" .
114 A positive response will cause
115 .Xr fsck 8
116 to convert the inode to a regular file containing the bad block.
117 .Sh SEE ALSO
118 .Xr fsck 8
119 .Sh DIAGNOSTICS
120 The
121 .Nm
122 utility refuses to attach a block that
123 resides in a critical area or is out of range of the file system.
124 A warning is issued if the block is already in use.
125 .Sh BUGS
126 If more than one sector which comprise a file system fragment are bad,
127 you should specify only one of them to
128 .Nm ,
129 as the blocks in the bad sector files actually cover all the sectors in a
130 file system fragment.
131 .Sh HISTORY
132 The
133 .Nm
134 utility appeared in
135 .Bx 4.1 .