1.\" Copyright (c) 1985, 1991 The 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.\" from: @(#)badsect.8 6.4 (Berkeley) 3/16/91 33.\" $Id: badsect.8,v 1.4 1993/08/01 07:39:41 mycroft Exp $ 34.\" 35.Dd March 16, 1991 36.Dt BADSECT 8 37.Os BSD 4 38.Sh NAME 39.Nm badsect 40.Nd create files to contain bad sectors 41.Sh SYNOPSIS 42.Nm /etc/badsect 43.Ar bbdir sector ... 44.Sh DESCRIPTION 45.Nm Badsect 46makes a file to contain a bad sector. Normally, bad sectors 47are made inaccessible by the standard formatter, which provides 48a forwarding table for bad sectors to the driver; see 49.Xr bad144 8 50for details. 51If a driver supports the bad blocking standard it is much preferable to 52use that method to isolate bad blocks, since the bad block forwarding 53makes the pack appear perfect, and such packs can then be copied with 54.Xr dd 1 . 55The technique used by this program is also less general than 56bad block forwarding, as 57.Nm badsect 58can't make amends for 59bad blocks in the i-list of file systems or in swap areas. 60.Pp 61On some disks, 62adding a sector which is suddenly bad to the bad sector table 63currently requires the running of the standard 64.Tn DEC 65formatter. 66Thus to deal with a newly bad block 67or on disks where the drivers 68do not support the bad-blocking standard 69.Nm badsect 70may be used to good effect. 71.Pp 72.Nm Badsect 73is used on a quiet file system in the following way: 74First mount the file system, and change to its root directory. 75Make a directory 76.Li BAD 77there. Run 78.Nm badsect 79giving as argument the 80.Ar BAD 81directory followed by 82all the bad sectors you wish to add. 83(The sector numbers must be relative to the beginning of 84the file system, but this is not hard as the system reports 85relative sector numbers in its console error messages.) 86Then change back to the root directory, unmount the file system 87and run 88.Xr fsck 8 89on the file system. The bad sectors should show up in two files 90or in the bad sector files and the free list. Have 91.Xr fsck 92remove files containing the offending bad sectors, but 93.Em do not 94have it remove the 95.Pa BAD/ Ns Em nnnnn 96files. 97This will leave the bad sectors in only the 98.Li BAD 99files. 100.Pp 101.Nm Badsect 102works by giving the specified sector numbers in a 103.Xr mknod 2 104system call, 105creating an illegal file whose first block address is the block containing 106bad sector and whose name is the bad sector number. 107When it is discovered by 108.Xr fsck 109it will ask 110.Dq Li "HOLD BAD BLOCK ?" 111A positive response will cause 112.Xr fsck 113to convert the inode to a regular file containing the bad block. 114.Sh SEE ALSO 115.Xr bad144 8 , 116.Xr fsck 8 , 117.Xr format 8 118.Sh DIAGNOSTICS 119.Nm Badsect 120refuses to attach a block that 121resides in a critical area or is out of range of the file system. 122A warning is issued if the block is already in use. 123.Sh BUGS 124If more than one sector which comprise a file system fragment are bad, 125you should specify only one of them to 126.Nm badsect , 127as the blocks in the bad sector files actually cover all the sectors in a 128file system fragment. 129.Sh HISTORY 130The 131.Nm 132command appeared in 133.Bx 4.1 . 134