10

I have a broken disk where I need to copy a 60G file from.

From time to time the disk resets and I can't finish the copy.

I would like to try and copy partial slices and put them all together.

How can I do this?

  • The old-fashioned (old school) way would be to use dd. – G-Man May 23 '15 at 22:22
  • 1
    Another option is to use e.g split -b[bytes] yourbigFile – Valentin Bajrami May 23 '15 at 22:38
  • 3
    If you are trying to copy the file from a bad disk then - ddrescue or no - you're probably going about it wrong. Because the file depends on the file-system, and because the file is very likely not contiguous, then doing the reads to get it from the faulty device is almost definitely going to require more disk-seeking than you can easily afford. I would Image the block device onto a known good device in as close to a single pass as I could get, and afterward focus recovery efforts on the mounted image file as much as possible. – mikeserv May 24 '15 at 10:00
14

Use ddrescue, which is designed for this type of scenario.

It uses a log file to keep track of the parts of the data that it has successfully copied - or otherwise. As a result you can stop and restart it as many times as necessary, provided that the log file is maintained.

See Ddrescue - Data recovery tool

4

Use dd.

It can do a lot, but you need the following form:

dd if=<source> of=<destination> bs=<block size> count=<blocks> skip=<offset>

E.g., to copy the 2nd to the 4th kilobyte from a file, you'd do:

dd if=in.dat of=out.dat bs=1K count=2 skip=2

Given the specifics of what you're trying to do, you can also try to add conv=sync,noerror:

dd if=in.dat of=out.dat bs=1K count=2 skip=2 conv=sync,noerror

The noerror makes it try to continue when it encounters an error, and the sync makes it pad failed blocks with zeroes. So ideally, you'd get the file you want, but with zeroes for the blocks it couldn't read. However, it depends on your harddisk what it'll actually do. Some harddisks just shut down when they see an error, and then you still won't get your data.

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.