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