1.\" Copyright (c) 1980, 1988, 1991 Regents of the University of California. 2.\" 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.\" @(#)bad144.8 6.7 (Berkeley) 3/16/91 33.\" 34.Dd March 16, 1991 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 59can be used to inspect the information stored on a disk that is used by 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. 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 101the information, described by the 102.Ar dkbad 103structure. 104.Pp 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 108of the bad sector in the bad sector table determines the replacement 109sector to which it corresponds. 110The bad sectors must be listed in ascending order. 111.Pp 112The bad sector information and replacement sectors are conventionally 113only accessible through the ``c'' file system partition of the disk. If 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. 117Thus, one track plus 126 sectors must be reserved to allow use 118of all of the possible bad sector replacements. 119.Pp 120The bad sector structure is as follows: 121.Bd -literal 122struct dkbad { 123 long bt_csn; /* cartridge serial number */ 124 u_short bt_mbz; /* unused; should be 0 */ 125 u_short bt_flag; /* -1 => alignment cartridge */ 126 struct bt_bad { 127 u_short bt_cyl; /* bad sector cylinder number */ 128 u_short bt_trksec; /* track and sector number */ 129 } bt_bad[126]; 130}; 131.Ed 132.Pp 133Unused slots in the 134.Ar bt_bad 135array are filled with all bits set, a putatively 136illegal value. 137.Pp 138.Nm Bad144 139is invoked by giving a device name (e.g. hk0, hp1, etc.). 140With no optional arguments 141it reads the first sector of the last track 142of the corresponding disk and prints out the bad sector information. 143It issues a warning if the bad sectors are out of order. 144.Nm Bad144 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 150.Nm bad144 151does not arrange for the specified sectors to be marked bad in this case. 152This procedure should only be used to restore known bad sector information which 153was destroyed. 154.Pp 155It is no longer necessary to reboot to allow the kernel 156to reread the bad-sector table from the drive. 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 164It should be possible to mark bad sectors on drives of all type. 165.Pp 166On an 11/750, 167the standard bootstrap drivers used to boot the system do 168not understand bad sectors, 169handle 170.Tn ECC 171errors, or the special 172.Tn SSE 173(skip sector) errors of RM80-type disks. 174This means that none of these errors can occur when reading the file 175.Pa /vmunix 176to boot. Sectors 0-15 of the disk drive 177must also not have any of these errors. 178.Pp 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. 182.Sh HISTORY 183The 184.Nm 185command appeared in 186.Bx 4.1 . 187