Simple Hard Drive Data Recovery


After a recent brush with hard drive failure, I wanted to put together a HOWTO on how to mirror a hard drive, ignoring errors under Linux. It is critical to ensure that these commands are issued correctly, and that the right drive and device names are used. dd offers no prompting and confirmation - use with caution!

Hard disk data recovery in the case of broken sectors is usually not too complicated.


Firstly, we need to determine the optimal I/O size to maximize our read and write speed:

fdisk -l /dev/sda|grep "I/O size"

In my case, the result shows 512 bytes. Next, assuming that our failed drive is /dev/sdb and our new drive is /dev/sdc we'll start the mirror as follows:

dd if=/dev/sdb of=/dev/sdc conv=sync,noerror bs=512

The noerror flag is passed to instruct dd not to quit on read errors

Progress Check

dd will print out a status check on receiving the USR1 signal. In a separate terminal, issue:

kill -USR1 $(pidof dd)


Often, after a run of bad sectors, dd's transfer speed will drop and remain throttled. To mitigate this, first stop the transfer with Ctrl-C allowing dd to print out it's current progress:

6002656+0 records in
6002656+0 records out
3073359872 bytes (3.1 GB) copied

Now ensure all data is flushed:


Once done, remove and reattach the drive, before continuing from where dd last left off:

dd if=/dev/sdb of=/dev/sdc bs=512 conv=sync,noerror seek=6002656 skip=6002656

Once complete, you'll want to scan the filesystem(s) of the new drive to detect and repair any file system errors and corruption.

IO Digital Sec

Share this page:

0 Comment(s)

Add comment