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