Finding bad sector to file mapping

User discussion and information resource forum for Image products.
Post Reply
BradTheGeek
Posts: 2
Joined: Tue Jul 14, 2015 4:36 pm

Finding bad sector to file mapping

Post by BradTheGeek »

Hi, I use IFW and IFL quite a bit. One common use is to image or clone a failing drive. If we are cloning and want to have a stable system after, it is sometimes good to know what files were affected by the bad sectors. TO that end I found this thread: http://www.terabyteunlimited.com/ucf/vi ... f=4&t=1278

Is the tool findlbaf or something similar available on the Image For Linux disk? I know I can turn the log level up to 10 and capture a log with the LBA addresses that were affected with both IFL and IFW, however a large part of my use case involves booting the PC with the failed drive into IFL since I have a limited number of Windows machines with IFW. Having use of this tool or similar inside of IFL would be amazing if possible.

Anyone know of a way to do this?

Thanks
TeraByte Support(TP)
Posts: 305
Joined: Wed Aug 31, 2011 4:22 pm

Re: Finding bad sector to file mapping

Post by TeraByte Support(TP) »

BradTheGeek wrote:
> Hi, I use IFW and IFL quite a bit. One common use is to image or clone a
> failing drive. If we are cloning and want to have a stable system after,
> it is sometimes good to know what files were affected by the bad sectors.
> TO that end I found this thread:
> http://www.terabyteunlimited.com/ucf/vi ... f=4&t=1278
>
> Is the tool findlbaf or something similar available on the Image For Linux
> disk? I know I can turn the log level up to 10 and capture a log with the
> LBA addresses that were affected with both IFL and IFW, however a large
> part of my use case involves booting the PC with the failed drive into IFL
> since I have a limited number of Windows machines with IFW. Having use of
> this tool or similar inside of IFL would be amazing if possible.
>
> Anyone know of a way to do this?

There's nothing like that in IFL now, but it looks like the 'ntfscluster' utility will do what you want (for NTFS partitions). It's part of the ntfsprogs set of utilities, and here's the manual page for it: http://linux.die.net/man/8/ntfscluster

You can use either the -c (cluster) or -s (sector) option to list any files that have data in a given range of clusters or sectors.

Since it's a fairly small utility, we'll just add it to the next IFL update.
BradTheGeek
Posts: 2
Joined: Tue Jul 14, 2015 4:36 pm

Re: Finding bad sector to file mapping

Post by BradTheGeek »

That is great! Do you know if the LBA address reported in the log file is the same as the sector number this program looks for? I would assume so.

Also, in case you are interested, I found another way to do this, but I doubt it would work with TBIs tools. If you use ddrescue to create a disk image (or clone), you can a tool called ddru_findbad to compare it's logfile and the image to generate an affected file list. This tool is part of ddrutility.

The downside is that making images in this way wastes space at it images the entire drive, including empty sectors. You can use another ddrutility tool to look at the NTFS bitmap and feed it into ddrescue to generate a smaller image, but this only works on a partition level, not the drive level. If you want to lay a bootable image back down on a new drive, including MBR, GPT, and HPA areas you need to have an image of the drive not individual partitions.

I look forward to seeing this tool on the next IFL version and giving it a run.
TeraByte Support(TP)
Posts: 305
Joined: Wed Aug 31, 2011 4:22 pm

Re: Finding bad sector to file mapping

Post by TeraByte Support(TP) »

BradTheGeek wrote:
> That is great! Do you know if the LBA address reported in the log file is
> the same as the sector number this program looks for? I would assume so.

It looks like you would have to subtract the starting LBA of the NTFS partition from the LBA address in the IFL/IFW log file. That's because the device specified on the 'ntfscluster' command line has to be an NTFS volume (partition), not an entire drive. The LBA addresses in the IFL/IFW log files are at the drive level. This of course is when using the -s (sector) option on the 'ntfscluster' command line.

Example: The error log shows LBA 100000 is a bad sector, and the starting LBA of NTFS partition /dev/sda1 is 2048
ntfscluster -s 97952-97952 /dev/sda1
ntfscluster -s 97952-97952 /dev/sda1 2> /dev/null (would filter out irrelevant lines)

I don't have any experience with this utility with actual bad sectors, but the results of a few quick tests on a good drive seem to make sense.


>
> Also, in case you are interested, I found another way to do this, but I
> doubt it would work with TBIs tools. If you use ddrescue to create a disk
> image (or clone), you can a tool called ddru_findbad to compare it's
> logfile and the image to generate an affected file list. This tool is part
> of ddrutility.
>
> The downside is that making images in this way wastes space at it images
> the entire drive, including empty sectors. You can use another ddrutility
> tool to look at the NTFS bitmap and feed it into ddrescue to generate a
> smaller image, but this only works on a partition level, not the drive
> level. If you want to lay a bootable image back down on a new drive,
> including MBR, GPT, and HPA areas you need to have an image of the drive
> not individual partitions.

I saw some information on the 'ddrutility' also, but it looked like 'ntfscluster' would be better to use wtih the TeraByte imaging porgrams.

> I look forward to seeing this tool on the next IFL version and giving it a
> run.

If you want to try it sooner, we can make a test version available with 'ntfscluster' added, if you send an email to support (support@terabyteunlimited.com) and request it.
Post Reply