Using dd with bad blocks on a harddrive

ddhard driveunix

I'm looking to use dd to make a clone of failing harddrive. My concern is there will be bad blocks for surely. So my question is with dd will a bad block leave a gap the size of the selected block-size(bs) or will it only be as big as the sector on the harddrive?

Best Answer

I'm pretty sure it'll be the larger of the two.

Let's say you're using a 512 byte block-size in dd, but your disk uses 4K sectors, and one of them is bad. All four 512-byte reads that dd tries to make of that 4K sector will fail, resulting in a 4K gap.

Now let's say you're using an 8K dd block-size but your disk uses 4K sectors. When dd attempts to do that 8K read, it will fail because one of the sectors in the read failed, resulting in an 8K gap.

Now is probably a good time to mention GNU ddrescue (not to be confused with the non-GNU software of the same name) which basically automates using dd to rescue a failing drive, with several efficiency tricks. It starts with a large block size for speed, but it keeps track of where it saw bad blocks and then goes back to try to read different parts of them with smaller read sizes, until it gets down to a list of absolutely unreadable 512-byte blocks. It took me a while to make sense of the documentation but once I figured it out, I found it to be a very useful tool and very preferable to using dd directly myself for this kind of task.

Related Question