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.16 2008/09/25 22:44:51 reed 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. 58The 59.Nm 60tool is only installed on supported platforms. 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 76.Pq vax only 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 int32_t bt_csn; /* cartridge serial number */ 125 u_int16_t bt_mbz; /* unused; should be 0 */ 126 u_int16_t bt_flag; /* -1 =\*[Gt] alignment cartridge */ 127 struct bt_bad { 128 u_int16_t bt_cyl; /* cylinder number of bad sector */ 129 u_int16_t 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 140is invoked by giving a device name (e.g. wd0, 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 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 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 154information which was 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.Sh HISTORY 161The 162.Nm 163command appeared in 164.Bx 4.1 . 165.Sh BUGS 166It should be possible to format disks on-line under 167.Bx 4 . 168.Pp 169It should be possible to mark bad sectors on drives of all type. 170.Pp 171On an 11/750, 172the standard bootstrap drivers used to boot the system do 173not understand bad sectors, 174handle 175.Tn ECC 176errors, or the special 177.Tn SSE 178(skip sector) errors of RM80-type disks. 179This means that none of these errors can occur when reading the file 180.Pa /netbsd 181to boot. Sectors 0-15 of the disk drive 182must also not have any of these errors. 183.Pp 184The drivers which write a system core image on disk after a crash do not 185handle errors; thus the crash dump area must be free of errors and bad 186sectors. 187