[clue-tech] filesystem: which sector is file x on?

Jim Ockers ockers at ockers.net
Wed Mar 7 20:23:55 MST 2007


Hi Dave,

Thanks for the reply & for thinking about this.

David L. Anselmi wrote:
> 
> Jim Ockers wrote:
> > Hi,
> > 
> > So someone asked me today how to tell which file is on a given
> > sector of a disk.  For instance if the kernel is throwing bad 
> > sector errors with sector number 1234567, how could we tell what
> > file in a filesystem is likely to be affected.
> [...]
> > This blog post states: http://prefetch.net/blog/index.php/category/linux-storage/
> > 
> > "all modern disk drive controllers contain logic to remap faulty sectors when they are detected"
> 
> It also says "We also used the ext3 file system debugger to see if a 
> file was using the block".
> 
> The debugger is debugfs.  So:
> 
> debugfs: icheck _block_
> 
> tells you which inode owns the bad block.  Then:
> 
> debugfs: ncheck _inode_
> 
> tells you the path to that inode (relative to the fs root).

Okay, so we can tell which file is using block x.  Remember that the 
block device appears to the filesystem as n consecutive blocks, all 
error free.

I don't think this says anything about what sector any block is on.
Remember in the physical drive there are heads, cylinders, and sectors.
(I think.)  The drive may report a sector error and give a sector 
number, but I don't think that sectors are the same as blocks.

That is, a bad sector may result in a bad block, but the sector and block
numbering is not the same.  The block device is not n sectors long, it is
n blocks long.  Also if data is moved from one sector to another by the
drive controller, this does not change the ordering of the blocks.  (If it
did, it would cause very weird filesystem problems.)

Any ideas how to dig into the drive to see what sectors the blocks are
on?

Thanks,
Jim

-- 
Jim Ockers, P.Eng. (ockers at ockers.net)
Contact info: please see http://www.ockers.net/



More information about the clue-tech mailing list