I just want to wrap up how I managed to recover the data from a laptop’s damaged hard disk drive. The 40GB disk was formatted with FAT32, had a Windows XP and some serious I/O error problems preventing it from booting.
I cleaned up my external 80 GB HDD, plugged it via USB into the laptop and booted the system with the latest Knoppix-CD. I reformatted the entire disk (/dev/sda1) with the ext3 file system, mounted it with (# mkdir /media/sda1 ; mount -t auto /dev/sda1 /media/sda1) and gave full access to the entire disk (# cd /media/sda1 ; chmod 777 *).
Since Knoppix is missing the dd_rhelp script, I downloaded the latest package and put it on that external disk (into /media/sda1/dd_rhelp). The damaged disk in the laptop was /dev/hda1. I set disk-access parameters for that disk back to basic but safe, disabling DMA and higher level PIO mode access:
# hdparm -m 0 -d 0 -p 0 -A 0 -X 08 /dev/hda
This makes things horribly slow in copying the large chunks of good data, but it improved the overall process since it can handle bad blocks in a better fashion. Next, I edited the dd_rhelp script and set the values “max_bs=1024” and “min_bs=64” in /media/sda1/dd_rhelp/dd_rhelp. The standard values of dd_rhelp are fine, but slow down the copying of data if the disk is damaged to a larger degree.
Ready to copy the data. Change to root with “su” and then run
# /media/sda1/dd_rhelp/dd_rhelp /dev/sda1 /media/sda1/sda1_backup.img
This process makes a bit-per-bit copy of the entire disk and writes it to the image sda1_backup.img. Any bit that cannot be read by the program will be zero. This takes a while. Quite a while. For my 40GB about a week. Which had nothing to do with the hdparm above but with the overall state of the disk (I ran the process twice). You may kill the dd_rhelp and the dd_rescue processes at any time and continue later on. dd_rhelp writes a log file that keeps track of the overall progress that has been made.
When you are done make a copy of the rescued image /media/sda1/sda1_backup.img and get yourself another hard drive that is at least as big as the image you just rescued or make some space on another hard drive. You will have to create a new FAT32 partition that is at least as big as the image. If the file system of the disk from where you just rescued the data has file system X, create a new X partition of that size. In my case, that new partition mounted as /media/sdb6. Now, copy the data from the image to that partition with
# dd if=/media/sda1/sda1_backup.img of=/dev/sdb6
Mounted /dev/sdb6 and saw the data. You can now run any file system/data/rescue operations on that disk (or the image file) or copy what’s left of it.
Update: compiled some data in a How To: Recover Windows Partitions.