Howto copy files from a damaged hard disk with Linux

August 24, 2011

I just got a hard disk which had bad blocks to try to rescue files, but which was too big to use dd_rescue to copy the whole partition on any other hard disk I had, before extracting the files. But in this case the file system directory structure was still readable, so I was able to use following method, which maybe helps someone else.

I mounted the file system read only with following mount -r /dev/sdb1 /mnt and than I created 2 shell scripts.

First File:

#!/bin/bash
cd /mnt/damagedHD/
mkdir /mnt/dirForExtractedFiles/
find . -type d -exec mkdir /mnt/dirForExtractedFiles/{} \;
find . -type f -exec /path2secondscript/rescue_copy.sh {} \;

Second File:

#!/bin/bash
if [ ! -f "/mnt/dirForExtractedFiles/$1" ]
then
dd_rescue "$1" "/mnt/dirForExtractedFiles/$1"
fi

I use 2 scripts as sometimes the hard disk runs into a problem and than stops working until it is powered down and up again. In this case I use CRTL-C to break the loop followed by commenting the first 3 commands in the first file out, and than start it again after the harddisk is mounted again. The “if”-query in the second file makes sure we won’t try files which we already have or the one which lead to the error in the first place.

Powered by WordPress
Entries and comments feeds. Valid XHTML and CSS. 25 queries. 0.046 seconds.