'\"macro stdmacro
.if n .pH g1a.hdefix @(#)hdefix	40.6.1.1 of 1/17/90
.\" Copyright 1989 AT&T
.nr X
.if \nX=0 .ds x} hdefix 1M "Essential Utilities" "\&"
.if \nX=1 .ds x} hdefix 1M "Essential Utilities"
.if \nX=2 .ds x} hdefix 1M "" "\&"
.if \nX=3 .ds x} hdefix "" "" "\&"
.TH \*(x}
.SH NAME
\f4hdefix\f1 \- report or change bad block mapping on a hard disk device
.SH SYNOPSIS
\f4/sbin/hdefix\f1
\f4\-p\f1
[
\f4\-D\f1
\f2major minor\f1 ]
.PP
\f4/sbin/hdefix\f1
\f4\-a\f1
[
\f4\-D\f1
\f2major minor\f1 [
\f4\-b\f1 \f2blockno\f1 ...
] ]
.PP
\f4/sbin/hdefix\f1
\f4\-a\f1
[
\f4\-D\f1
\f2major minor\f1 [
\f4\-B\f1 \f2cyl trk sec\f1 ...
] ]
.SH DESCRIPTION
The \f4hdefix\fP  command is part of the bad block handling utility.
This command maps bad blocks to surrogate images in
an area not accessible by the user.
.PP
Before attempting to execute \f4hdefix\fP, the system must
be brought to the single-user state using the command \f4init s\fP.
Only super-user can use
\f4hdefix\fP
to print a list of blocks currently mapped to surrogate
images on the equipped hard disk devices or to change the
mapping of these blocks.
.PP
When the mapping to surrogate images is changed, block initialization
is performed.
If the original block can be read, its data is written
to the new surrogate image to prevent data loss. 
If the original
block is unreadable, zeros are written to the new surrogate image.
This will usually result in some data loss.
.PP
If the block is associated with a file system,
the file system may be damaged as a result of the mapping change.
To handle this situation,
the file system is marked dirty, which means
the \f4fsck\fP command
must be run before the file system can be used,
and a system reboot is forced
after all other bad block processing is complete.
If the block is a data block of a file,
that file will be corrupted, even after
this recovery has finished.
.PP
The following options may be used with \f4hdefix\fP:
.PP
.TP .75i
\f4\-p\f1
prints a report that shows both the functional blocks and currently
mapped bad blocks.
If a specific hard disk device is specified (by giving its
.I major
and
.I minor
device numbers),
only the report for that hard disk device is printed.
If no particular hard disk device is specified,
a report is given for each equipped disk.
.TP
\f4\-D\f1
used to specify the \f2major\fP device number
and \f2minor\fP device number of a hard disk device.
.TP
\f4\-a\f1
used to map new bad blocks.
If no arguments follow the
\f4\-a\f1
option, all equipped hard disk devices are processed, using the \s-1HDE\s0 Log
on each hard disk device to determine which blocks to map.
If a specific hard disk device is specified, only that disk
device is processed.
If one or more block numbers are specified, those blocks
are mapped, instead of using the block numbers listed in \s-1HDE\s0 Log.
This is the only way to map an unreadable block containing the \s-1HDE\s0 Log.
.TP
\f4\-b\fP \f2blockno\fP
specifies the physical hard disk block number.
Physical hard disk block numbering starts with zero, meaning
block (sector) 0 of track 0 of cylinder 0.
The
.I blockno
value ranges from block number 0 through the maximum number of
blocks on a particular hard disk drive minus 1.
.TP
\f4\-B\f2 cyl trk sec\f1
specifies the physical disk block number in terms of its
physical cylinder number (\f2cyl\f1), track number within
cylinder (\f2trk\f1), and sector (block) number within track
(\f2sec\f1).
This alternate form is available for reporting bad block data
obtained without using the normal system capabilities (e.g.,
off-line diagnostics provided by the manufacturer).
This option is not supported on \s-1SCSI\s0 disks.
.SH FILES
\f4/dev/hdelog\f1
.SH "SEE ALSO"
\f4fsck\fP(1M), \f4init\fP(1M), \f4hdeadd\fP(1M), \f4hdelogger\fP(1M), \f4hdelog\fP(7).
.br
.I "Bad Block Handling"
in the
.IR "System Administrator's Guide" .
.SH RETURN CODES
The \f4hdefix\fP command exits with one of three values:
.TP .5i
0
means \s-1NORMAL\s0 (or \s-1TRUE\s0)
.TP
1
means bad command usage or execution errors
.TP
2
means \s-1BAD BLOCKS\s0 (or \s-1FALSE\s0) (but command executed successfully)
.Ee
