files and disk sectors

Lennart Sorensen lsorense-1wCw9BSqJbv44Nm34jS7GywD8/FfD2ys at public.gmane.org
Wed Feb 4 19:00:17 UTC 2009


On Wed, Feb 04, 2009 at 01:44:33PM -0500, Matt Price wrote:
> while i'm thinking about this, is there a way to tell which files sit on
> a particular disk sector?  something is accessing the bad sector on my
> disk over and over again, presumably reading a config file or something;
> if i could move that file to another sector things might get better for
> me.
> 
> thx,
> matt
> 
> ps i know i should get rid of the disk, or at least reformat and
> restore, but i have a lot of big video files on this disk, for which i
> have no backup space at the moment, and hwile it wouldn't kill me to
> lose them i'd stil lrather not.  anyway appreciate the help as always...

Try debugfs (in read only mode and with the filesystem mounted readonly)
and use icheck to find the inode number using the block (mapping block
to sector is going to be a different problem).

Often the block size is 4k, but you can check with tune2fs -l on the
device.  If it is 4k, well then your block number would be 1/8th of the
sector number.  So sector 2 is in block 0, sector 14 is in block 1,
sector 55 is in block 6, etc.

Of course you have to adjust the sector from starting at the begining of
disk to starting at the begining of the partition, so check the start
location of the partition using fdisk -lu to get the sector the
partition starts on, and subtract that from the physical sector number.

So if your sector number was 123456789 and your partition starts at
sector 240000, you would get sector 123216789 on the partition which
would then be block 15402098 on the partition (and hence of the
filesystem).  icheck 15402098 in debugfs on the partition should then
hopefully give you which inode number is using that block (and hence
sector).  Then use ncheck with the inode number to get a list of paths
which refer to that inode number.  This should hopefully find the file
you are dealing with.

-- 
Len Sorensen
--
The Toronto Linux Users Group.      Meetings: http://gtalug.org/
TLUG requests: Linux topics, No HTML, wrap text below 80 columns
How to UNSUBSCRIBE: http://gtalug.org/wiki/Mailing_lists





More information about the Legacy mailing list