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