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