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. Neither the name of the University nor the names of its contributors 13.\" may be used to endorse or promote products derived from this software 14.\" without specific prior written permission. 15.\" 16.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 17.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 20.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26.\" SUCH DAMAGE. 27.\" 28.\" from: @(#)bad144.8 8.1 (Berkeley) 6/6/93 29.\" $NetBSD: bad144.8,v 1.15 2003/08/07 11:25:12 agc Exp $ 30.\" 31.Dd June 6, 1993 32.Dt BAD144 8 33.Os 34.Sh NAME 35.Nm bad144 36.Nd read/write DEC standard 144 bad sector information 37.Sh SYNOPSIS 38.Nm 39.Op Fl c 40.Op Fl f 41.Op Fl v 42.Ar disk 43.Oo 44.Ar sno 45.Op Ar bad ... 46.Oc 47.Nm 48.Fl a 49.Op Fl c 50.Op Fl f 51.Op Fl v 52.Ar disk 53.Op Ar bad ... 54.Sh DESCRIPTION 55.Nm 56can be used to inspect the information stored on a disk that is used by 57the disk drivers to implement bad sector forwarding. 58.Pp 59Available options: 60.Pp 61.Bl -tag -width Ds 62.It Fl a 63The argument list consists of new bad sectors to be added to an existing 64list. 65The new sectors are sorted into the list, 66which must have been in order. 67Replacement sectors are moved to accommodate the additions; 68the new replacement sectors are cleared. 69.It Fl c 70Forces an attempt to copy the old sector to the replacement, 71and may be useful when replacing an unreliable sector. 72.It Fl f 73.Pq vax only 74For a RP06, RM03, RM05, Fujitsu Eagle, 75or 76.Tn SMD 77disk on a MASSBUS, the 78.Fl f 79option may be used to mark the new bad sectors as ``bad'' 80by reformatting them as unusable sectors. 81This option is 82.Em required unless 83the sectors have already been marked bad, 84or the system will not be notified that it should use the replacement sector. 85This option may be used while running multiuser; it is no longer necessary 86to perform format operations while running single-user. 87.It Fl v 88The entire process is described as it happens in gory detail if 89.Fl v 90(verbose) is given. 91.El 92.Pp 93The format of 94the information is specified by 95.Tn DEC 96standard 144, as follows. 97The bad sector information is located in the first 5 even numbered sectors 98of the last track of the disk pack. There are five identical copies of 99the information, described by the 100.Ar dkbad 101structure. 102.Pp 103Replacement sectors are allocated starting with the first sector before 104the bad sector information and working backwards towards the beginning 105of the disk. A maximum of 126 bad sectors are supported. The position 106of the bad sector in the bad sector table determines the replacement 107sector to which it corresponds. 108The bad sectors must be listed in ascending order. 109.Pp 110The bad sector information and replacement sectors are conventionally 111only accessible through the ``c'' file system partition of the disk. If 112that partition is used for a file system, the user is responsible for 113making sure that it does not overlap the bad sector information or any 114replacement sectors. 115Thus, one track plus 126 sectors must be reserved to allow use 116of all of the possible bad sector replacements. 117.Pp 118The bad sector structure is as follows: 119.Bd -literal 120struct dkbad { 121 int32_t bt_csn; /* cartridge serial number */ 122 u_int16_t bt_mbz; /* unused; should be 0 */ 123 u_int16_t bt_flag; /* -1 =\*[Gt] alignment cartridge */ 124 struct bt_bad { 125 u_int16_t bt_cyl; /* cylinder number of bad sector */ 126 u_int16_t bt_trksec; /* track and sector number */ 127 } bt_bad[126]; 128}; 129.Ed 130.Pp 131Unused slots in the 132.Ar bt_bad 133array are filled with all bits set, a putatively 134illegal value. 135.Pp 136.Nm 137is invoked by giving a device name (e.g. wd0, hk0, hp1, etc.). 138With no optional arguments 139it reads the first sector of the last track 140of the corresponding disk and prints out the bad sector information. 141It issues a warning if the bad sectors are out of order. 142.Nm 143may also be invoked with a serial number for the pack and a list 144of bad sectors. 145It will write the supplied information into all copies 146of the bad-sector file, replacing any previous information. 147Note, however, that 148.Nm 149does not arrange for the specified sectors to be marked bad in this case. 150This procedure should only be used to restore known bad sector 151information which was destroyed. 152.Pp 153It is no longer necessary to reboot to allow the kernel 154to reread the bad-sector table from the drive. 155.Sh SEE ALSO 156.Xr badsect 8 157.Sh HISTORY 158The 159.Nm 160command appeared in 161.Bx 4.1 . 162.Sh BUGS 163It should be possible to format disks on-line under 164.Bx 4 . 165.Pp 166It should be possible to mark bad sectors on drives of all type. 167.Pp 168On an 11/750, 169the standard bootstrap drivers used to boot the system do 170not understand bad sectors, 171handle 172.Tn ECC 173errors, or the special 174.Tn SSE 175(skip sector) errors of RM80-type disks. 176This means that none of these errors can occur when reading the file 177.Pa /netbsd 178to boot. Sectors 0-15 of the disk drive 179must also not have any of these errors. 180.Pp 181The drivers which write a system core image on disk after a crash do not 182handle errors; thus the crash dump area must be free of errors and bad 183sectors. 184