.TH bad "" "" Command
.PC "Maintain list of bad blocks"
\fBbad [\-acdl] \fIdevice\fB [ \fIblock ... \fB]\fR
.PP
.HS
.SH Options:
.IC \fBa\fR
Add blocks
.IC \fBc\fR
Clear bad-block list
.IC \fBd\fR
Delete blocks
.IC \fBl\fR
List blocks
.HE
A hard disk or floppy disk may have bad blocks on it:
a \*(QLbad block\*(QR is a portion of disk that is flawed,
and so cannot reliably be read or written.
It is the unusual disk that is free of bad blocks.
.PP
\*(CO keeps a list of bad blocks so it can avoid using them.
The command
.B bad
maintains this bad-block list for the given
.IR device ,
which must be a block-special file.
.B bad
recognizes the following command-line options:
.DS
.ta 0.4i
\fBa\fR	Add each given \fIblock\fR to the bad-block list
\fBc\fR	Clear the bad-block list
\fBd\fR	Delete each given \fIblock\fR from the bad-block list
\fBl\fR	List all blocks on the bad-block list
.DE
.PP
Note that
.B bad
merely adds a block to the list of bad blocks, or removes a block from that
list.
It does not deallocate any i-node associated with a block when
adding it to the bad-block list.
You should run the command
.B icheck
with the option
.B \-s
immediately after
.B bad
to correct the problem, or run the command
.BR fsck .
After you modify the list of bad blocks, you must reboot your system to
force the kernel to use this modified list.
.PP
The file system on
.I device
should be unmounted if possible.
You must have appropriate permissions for
.I device
before you can invoke
.BR bad .
For many file systems, only the superuser may use
.B bad
to change the bad-block list.
Use the command
.B badscan
to create a prototype file of bad blocks.
.PP
When the command
.B mkfs
creates a file system, the prototype specification may include a list of bad
blocks for the new file system.
.SH "See Also"
.Xr badscan, badscan
.Xr commands, commands
.Xr icheck, icheck
.Xr mkfs mkfs
