Determining which files got lost/corrupted with bad sectors?

cycleback

n00b
Joined
Oct 13, 2009
Messages
23
I had a 2 TB WD Green drive on a Windows 7 system start to fail last night. The computer started really slowing down and partially locking up when I attempted to write a file to the drive. I shutdown as quick as I could and connected a spare drive to make an image ASAP. During the imaging process it encountered bad sectors which I had the imaging program skip. I let it image overnight using O&O DiskImage as it was pretty slow and woke in the morning to find that it had started to validate the image (I was hoping to avoid extra stress on the failing drive by validating the image) but it was half done and I wanted some kind of indication off how good the image was. Four defective sectors were reported compared to the image. I have the bad sector numbers that it reported.

1) Is there anyway to figure out from the bad sector numbers determine which files are missing or corrupted?

The image itself is substantially smaller than the disk space occupied on the original drive. The original 2 TB drive was almost full and the image is about 200 GB smaller in size. While I turned on the only image used space option and compressor I am surprised that the image is that much smaller give that almost all of the files are media which is already heavily compressed.

2) Does this likely mean that large numbers of files are in reality missing? I didn't see anything obvious missing when I mounted the image but there are thousands of files. Any explanation for this behavior?

3) Is it worth trying to re-image the dying drive using a Linux live CD and dd_rescue? What about trying to force a read of the bad sectors? Has anyone had any success with that?
 
Have you checked the system logs?

You can run Windows chkdisk and it will usually tell you what files have been corrupted.

There are some programs that will attempt to read the damaged sectors over and over again, but the info they give at times can be just guesses.
 
Have you checked the system logs?
I looked through the system logs and didn't see any obvious errors.
You can run Windows chkdisk and it will usually tell you what files have been corrupted.
I am vary of running chkdisk because in the past it has seen to make the corruption worse.
There are some programs that will attempt to read the damaged sectors over and over again, but the info they give at times can be just guesses.
Is the best option dd_rescue?
 
I do not know of an easy method without you having an md5 (or similar) listing of every file in your system. And remember to do any detection on the copy not the original. chkdsk on a bad disk can make a bad situation worse.
 
It's pretty straightforward, in fact I did it today.

The error messages from /var/log/syslog have the CDB which has the sector number in hex. Arithmetic on the partition table is simple to figure the offset inside the raw device the filesystem lives on. Then you can use debugfs to first ask whether a certain block is in use (a quick operation), if so which inode (file) it belongs to (slow operation) and finally you can ask debugfs for filenames (directory entries) using that inode.

http://smartmontools.sourceforge.net/badblockhowto.html

Things get more complicated if you have md RAID in there, but not catastrophic. Use --query and/or --detail on the component devices to get the data offset. The block numbers might have to be multiplied depending on raid level.
 
Ah, I'm trying to recover my HDD now. I can peek at the files, but some folders are missing and such. Getting a lot of i/o errors with dd.

Well, thank goodness for backups. Though it's going to take a while (cloud based).

I'm going to read that dd_rescue vs ddrescue thing now - hopefully have some luck with it.
 
Can you be more specific? The real error message (media error or whatever) is in /var/log/whateveryourkernelmessages

Might want to try the freezer trick if you get a lot of errors.
 
Well, for me it failed to mount in windows, worked in ubuntu though but here's a screenshot of the errors I was getting with dd (sorry for phone, didn't want to disturb the system)

http://i.imgur.com/6bXhUNc.jpg

I tried using dd_rescue and that had looads of errors and I could hear the disk just clicking. Using ddrescue now (per your recommendation) and it seems to be working well so far. ~40GB of 500 copied so far onto a 1.5TB USB HDD.
 
No you need the kernel message from the logfile or dmesg to get the actual sector number,
 
Oh, sorry I think you're trying to answer OP's question while I was just in here thread jacking. I'll let OP have the floor again..
 
Back
Top