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