4

I am copying from a damaged HDD (not SDD) where about 15% files would cause I/O error. I only want the rest of the 85% complete files, and get a list of damanged files. How to do that?

cp stops on the first read error. scp/rsync complains and deletes the copy (wanted) and quit (unwanted). There is no way to continue after an I/O error, at least not found by reading rsync(1) manual.

I Googled for a long while, all posts are about other needs:

  1. telling the poster that the IO error means hard disk is damanged (I know it);
  2. telling the poster a way to copy the good sections of a single file, fill damaged data with zeros (I have 100k files each less than 10KB, and damanged files are no use to me, even if only one byte is missing);
  3. telling the poster how to repeattedly run rsync (over network) to fight bad connection and finish the copy.
  4. telling the poster how to change default timeout to let rsync try harder to read the files (I don't wish to do this)
  5. telling the poster to run fsck to fix the file system error.

Thanks for reading the list of unwanted answers!

Note: This is a disk with physical damage, confirmed by the proper diagnostic tools. I've also run a thorough fsck.

4

rsync --ignore-errors seems to do the trick, so far. I didn't expect it to work because the manual says:

   --ignore-errors
          Tells --delete to go ahead and delete files even when there are I/O errors.

where I didn't use --delete option at all.

  • Did it turn out to work as expected? (You're writing "seems to do the trick, so far") – Kristian Oct 4 '18 at 18:55
  • @Kristian it must have worked as expected for my case back in 2013. – Tankman六四 Oct 6 '18 at 9:32
1

You can use GNU ddrescue to create an image of the partition, skipping the bad sectors. Then, when you mount the image read-only, you will either get quick filesystem errors when acessing certain folders, or some files with zeroed data. Here and here are some tutorials for ddrescue.

  • Thanks but... I explained in the original question that having some files with zero data doesn't help. I need either the full file or no file at all. Quote from the question: "I have 100k files each less than 10KB, and damanged files are no use to me, even if only one byte is missing". – Tankman六四 Nov 22 '13 at 12:32
  • @ZhangWeiwu sorry I missed that part. However, if by any reason rsync doesn't work (some errors may give very long timeouts and make the process eternal), there are also tools to identify the bad files in a ddrescue image. – Aleix Mercader Nov 22 '13 at 12:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.