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.

2 Answers 2

6

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.

2
  • Did it turn out to work as expected? (You're writing "seems to do the trick, so far")
    – Kristian
    Commented Oct 4, 2018 at 18:55
  • @Kristian it must have worked as expected for my case back in 2013. Commented Oct 6, 2018 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.

2
  • 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". Commented Nov 22, 2013 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. Commented Nov 22, 2013 at 12:50

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .