I have a failed hard drive which I need to extract data from. My dd kung fu is failing me right now. I know that the drive is failing at sector 60515007 to 60517093 (512b per sector), and multiple other locations. and I need to skip that area. How do I do it in dd? And I need to compress it on the fly (piping maybe?). Can you recommend a good compression algorithm for that?


1 Answer 1


If you really want to do this with dd, you need to split your reads up:

dd if=/dev/sda bs=512 count=60515006 | gzip -9 > dump1.gz

will dump the first 60515006 sectors of /dev/sda to dump1.gz, compressing with gzip. Then

dd if=/dev/sda bs=512 skip=60517093 count=... | gzip -9 > dump2.gz

will skip the failed part and dump the next however many sectors you need to dump2.gz.

If you can spare the disk capacity somewhere, I would highly recommend using ddrescue instead; it can copy failed disks automatically (it doesn't stop on I/O errors). It will work much faster than dd (it starts with large block reads and only reads smaller amounts where necessary to retrieve data around failed sections) and avoid your having to figure out all the skips etc. It doesn't support compressed output though since it needs to seek around the output file.

You must log in to answer this question.

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