[comp.unix.wizards] Location of bad blocks

voorst@wybbs.UUCP (Dale Van Voorst) (05/05/89)

Does a program exist that will tell you what file, if any, a bad block is
being used by, given one or all of the following: (head/cylinder/sector)?

If none is available, is it possible to write a C program that could figure
this out.  It wouldn't have to be speedy, just so it could do it.

I have had the situation arise several times lately where a hard disk
error occurs and needs to be logged out.  I think it would be EXTREMELY
useful if you could find out which file, if any, has been corrupted.
This would save having to restore any data from backup if the bad spot
was not in an area being used by a permanent file.

Before I started trying to figure out a program to give me this information
I thought I'd send it past everyone on the net.

Any file system guru's out there with some insight??

(I am using machines with both Xenix (Altos,SCO 2.2) and Unix System V (Altos))

Thanks for any input,
Dale Van Voorst
voorst@wybbs

tropp@ce.chalmers.se. (Ulf Tropp) (05/09/89)

In article <146@wybbs.UUCP> voorst@wybbs.UUCP (Dale Van Voorst) writes:
>Does a program exist that will tell you what file, if any, a bad block is
>being used by, given one or all of the following: (head/cylinder/sector)?
>
Try icheck(8) and ncheck(8).
icheck -b blocknumber specialdevice
will propably give you the inode the block is owned by (or the free list).
ncheck -i inode specialdevice
will then give you the filename(s). Sometimes the inode(s) itself is
in a bad block. The information given by icheck is somewhat system specific.
If your vendor has decided that these commands are obsolete, since fsck(8)
is much better, you are out of luck. Blocknumber is of course 
calculated from head/cyl/sec and the geometry of the disk, but
beware that the numbers reported may be relative to the beginning of the
disk, not the beginning of the file system.
There may be a program called fsdb(8?) on your system, but i know nothing
about that one.
This procedure works in v7 and BSD, so you have a chance.

Ulf Tropp, tropp@ce.chalmers.se