Having just had a hard disk die on me, taking all my work with it (annoyingly I couldn’t find my old backup CD) I thought i’d document the steps I took to recover data from the Linux partition that it was on.
First off, as soon as the disk started making any noises and showing signs of going, I removed it and limped along until a replacement arrived, while this is not always practical when a disk starts going it is a good idea to be gentle with it.
With the new disk in my PC and formatted and re-installed, I started to try and get the data back from the dying disk.
With plenty of space (enough for the partition I wanted) I ran ‘dd’ to copy the actual partition. Once you have an image of the drive it will be more reliable to work on, especially if the drive is near the end of its life.
dd if=/dev/hda1 of=/tmp/disk.img bs=512 conv=noerror,sync
While this produced a lot of errors, I left it to carry on (the partition I was working on was 15GB).
When this completed, I was left with a 15GB file on my disk, a direct image of the broken partition (give or take a selection of un readable blocks)
From this, I was able to then run e2fsck on the backup image. To enable me to then mount the image as a loopback device.
mount /tmp/disk.img /mnt/tmkdisk -o loop and then browse into it to copy out the vital data I needed.
I have no idea if this little snippet will help anyone but it might.
In my travels for data recover tools, I came accross a few useful tools that could help to retrieve data from even more damaged partitions
http://www.guzu.net/linux/e2retrieve.php – e2retrieve
http://e2salvage.sourceforge.net/ – e2salvage
http://enraptured.dreamscape.org/toolkit/ – e2extract