		Using the formatdisk and reassignblock Utilities


Occasionally, SCSI disk drives fail in such a way that they become unusable because of bad sectors.  Such drives do not neccessarily need to be replaced. Two utilities are avaialable to repair drives with bad sectors.  One utility, called reassignblock, attempts to remap a known bad sector to a new location on the disk.  The other utility, called formatdisk, performs a surface-level format of the entire disk. 

reassignblock

The reassignblock command is used when one particular sector (block) is known to be bad.  This is typically used when messages of the following form are seen in the console following disk I/O failure:

Target 0: MEDIA ERROR; block 7D0H retry
Target 0: MEDIA ERROR; block 7D0H retry
...
Target 0: MEDIA ERROR; block 7D0H retry
SCSI Block in error = 2000; Partition a  F.S. sector 1840

This message means that SCSI target 2 encountered an unrecoverable media error at block 2000.  In this case, SCSI block 2000 was associated with File System Block 1840 in disk partition a.  If (and only if) the error is a MEDIA ERROR, the reassignblock utility can be of use.  What we would like to do is repair just that one block, without disturbing the rest of the disk.  Here is how one does this.  As superuser, type

reassignblock raw_device SCSI_block_number [-r]

Where

raw_device is /dev/rsd0a, /dev/rsd1a, etc.

SCSI_block_number, for example, is 2000 in the above case

-r, when specified, causes the reassignblock program to attempt to recover the data in the block being relocated before executing the Reassign Block command.  The program will attempt up to 20 reads of the sector.  If any one attempt succeeds, the program executes the Reassign Block command and rewrites the recovered data to the newly mappped block.  If all 20 attempts fail, the user will be notified:

			...Could not recover block 2000 after 20 attempts.
Reassign anyway (y/anything)? 


Responding with anything other than 'y' causes the program to abort.  Responding with 'y' causes a certain loss of user data.

It should be noted that the drive performs the actual block remapping; the algorithms by which the remapping take place are transparent to the operating system.  Also, each drive has a fixed (and small) number of spare locations available; repeated use of the reassignblock utility may result in all spares being used up.  In this case, the disk will have to be reformatted (see the formatdisk utility).

Also note that some drives will be incapable of successfully executing a Reassign Block command.  This may occur when the entire track containing the block to be remapped is unreadable.  A media error will be logged to the console in this case and reassignblock will terminate with the following message:

***REASSIGN BLOCK COMMAND FAILED


