xref: /netbsd/usr.sbin/bad144/bad144.8 (revision c4a72b64)
1.\" Copyright (c) 1980, 1988, 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 acknowledgement:
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.\"     from: @(#)bad144.8	8.1 (Berkeley) 6/6/93
33.\"	$NetBSD: bad144.8,v 1.11 2002/06/13 15:25:58 wiz Exp $
34.\"
35.Dd June 6, 1993
36.Dt BAD144 8
37.Os
38.Sh NAME
39.Nm bad144
40.Nd read/write dec standard 144 bad sector information
41.Sh SYNOPSIS
42.Nm
43.Op Fl c
44.Op Fl f
45.Op Fl v
46.Ar disk
47.Oo
48.Ar sno
49.Op Ar bad ...
50.Oc
51.Nm ""
52.Fl a
53.Op Fl c
54.Op Fl f
55.Op Fl v
56.Ar disk
57.Op Ar bad ...
58.Sh DESCRIPTION
59.Nm
60can be used to inspect the information stored on a disk that is used by
61the disk drivers to implement bad sector forwarding.
62.Pp
63Available options:
64.Pp
65.Bl -tag -width Ds
66.It Fl a
67The argument list consists of new bad sectors to be added to an existing
68list.
69The new sectors are sorted into the list,
70which must have been in order.
71Replacement sectors are moved to accommodate the additions;
72the new replacement sectors are cleared.
73.It Fl c
74Forces an attempt to copy the old sector to the replacement,
75and may be useful when replacing an unreliable sector.
76.It Fl f
77.Pq vax only
78For a RP06, RM03, RM05, Fujitsu Eagle,
79or
80.Tn SMD
81disk on a Massbus, the
82.Fl f
83option may be used to mark the new bad sectors as ``bad''
84by reformatting them as unusable sectors.
85This option is
86.Em required unless
87the sectors have already been marked bad,
88or the system will not be notified that it should use the replacement sector.
89This option may be used while running multiuser; it is no longer necessary
90to perform format operations while running single-user.
91.It Fl v
92The entire process is described as it happens in gory detail if
93.Fl v
94(verbose) is given.
95.El
96.Pp
97The format of
98the information is specified by
99.Tn DEC
100standard 144, as follows.
101The bad sector information is located in the first 5 even numbered sectors
102of the last track of the disk pack.  There are five identical copies of
103the information, described by the
104.Ar dkbad
105structure.
106.Pp
107Replacement sectors are allocated starting with the first sector before
108the bad sector information and working backwards towards the beginning
109of the disk.  A maximum of 126 bad sectors are supported.  The position
110of the bad sector in the bad sector table determines the replacement
111sector to which it corresponds.
112The bad sectors must be listed in ascending order.
113.Pp
114The bad sector information and replacement sectors are conventionally
115only accessible through the ``c'' file system partition of the disk.  If
116that partition is used for a file system, the user is responsible for
117making sure that it does not overlap the bad sector information or any
118replacement sectors.
119Thus, one track plus 126 sectors must be reserved to allow use
120of all of the possible bad sector replacements.
121.Pp
122The bad sector structure is as follows:
123.Bd -literal
124struct dkbad {
125	int32_t   bt_csn;		/* cartridge serial number */
126	u_int16_t bt_mbz;		/* unused; should be 0 */
127	u_int16_t bt_flag;		/* -1 =\*[Gt] alignment cartridge */
128	struct bt_bad {
129		u_int16_t bt_cyl;	/* cylinder number of bad sector */
130		u_int16_t bt_trksec;	/* track and sector number */
131	} bt_bad[126];
132};
133.Ed
134.Pp
135Unused slots in the
136.Ar bt_bad
137array are filled with all bits set, a putatively
138illegal value.
139.Pp
140.Nm
141is invoked by giving a device name (e.g. wd0, hk0, hp1, etc.).
142With no optional arguments
143it reads the first sector of the last track
144of the corresponding disk and prints out the bad sector information.
145It issues a warning if the bad sectors are out of order.
146.Nm
147may also be invoked with a serial number for the pack and a list
148of bad sectors.
149It will write the supplied information into all copies
150of the bad-sector file, replacing any previous information.
151Note, however, that
152.Nm
153does not arrange for the specified sectors to be marked bad in this case.
154This procedure should only be used to restore known bad sector
155information which was destroyed.
156.Pp
157It is no longer necessary to reboot to allow the kernel
158to reread the bad-sector table from the drive.
159.Sh SEE ALSO
160.Xr badsect 8
161.Sh HISTORY
162The
163.Nm
164command appeared in
165.Bx 4.1 .
166.Sh BUGS
167It should be possible to format disks on-line under
168.Bx 4 .
169.Pp
170It should be possible to mark bad sectors on drives of all type.
171.Pp
172On an 11/750,
173the standard bootstrap drivers used to boot the system do
174not understand bad sectors,
175handle
176.Tn ECC
177errors, or the special
178.Tn SSE
179(skip sector) errors of RM80-type disks.
180This means that none of these errors can occur when reading the file
181.Pa /netbsd
182to boot.  Sectors 0-15 of the disk drive
183must also not have any of these errors.
184.Pp
185The drivers which write a system core image on disk after a crash do not
186handle errors; thus the crash dump area must be free of errors and bad
187sectors.
188