Block to i-node to file name (was Re: uncorrectable disk error)

cpghost cpghost at cordula.ws
Mon Aug 20 18:40:10 PDT 2007


On Tue, Aug 21, 2007 at 01:04:38AM +0200, Wojciech Puchar wrote:
> ad4: FAILURE - READ_DMA48 status=51<READY,DSC,ERROR> 
> error=40<UNCORRECTABLE> LBA=465628608
> g_vfs_done():ad4a[READ(offset=238401650688, length=638976)]error = 5
> 
> how can i find (UFS2) what file uses that block?

[I took the liberty to change the subject for better archival]

Unless you're an fs guru or very patient and careful, you probably
won't or would have a hard time. But don't give up yet!

Try the following procedure:

1. Determine the slice where the block is located (fdisk)

2. Determine the partition of the block (bsdlabel)

3. Calculate the partition-relative offset of the block
   (i.e. subtract the slice offset and subtract from the
   result the partition offset).

4. Fire up fsdb(8) with the -r option on that file system.

5. Use fsdb's "findblk" command with that fs-relative offset
   to determine the inode that is holding this block. From "man fsdb":

     findblk disk block number ...
             Find the inode(s) owning the specified disk block(s) number(s).
             Note that these are not absolute disk blocks numbers, but offsets
             from the start of the partition.

   Keep in mind that the block could also be in the free list
   (unused); but you'd not get this error message if it was (?).

6. Verify that the resulting i-node number is the right one
   by jumping to that inode with the "inode" command of fsdb,
   and rechecking that this block is indeed held by this i-node
   with the "blocks" command of fsdb. (you may want to run fsdb
   in a script(1), to capture the potentially long list of blocks).

7. The inode number you get won't tell you the name of the file.
   To find this, scan all directories of that file system for this
   inode number (I'd write a small C proggy for that, but you could
   just as well use find(1)'s -inum switch.

   If your disk is dying, this can (wether with a C program or with
   find(1) crash your system. If the number of directories is
   not very high, you could try to use fsdb(8) for that.

BEWARE: Always use fsdb(8) with the read-only flag -r! You could
irrevocably damage your file system otherwise if you don't know
exactly what you're doing.

Good luck!

Regards,
-cpghost.

P.S.: We really need a little LBA to i-node utility for UFS/UFS2,
that we could combine with find /fs -inum <n>...! If possible, a
utility that also takes care of GEOM-ified disks etc...

-- 
Cordula's Web. http://www.cordula.ws/


More information about the freebsd-questions mailing list