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?
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It only takes a minute to sign up.Sign up to join this community
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.
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
dd if=in.dat of=out.dat bs=1K count=2 skip=2 conv=sync,noerror
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.