Rescue Data from Failing Partition January 21, 2006Posted by Carthik in administration, applications, commands, guides, ubuntu.
If you have a hard disk drive, or a drive partition that is failing, or if you want to copy data from one partition to another (don’t we all, at some time or the other?), then ddrescue comes to the rescue!
In case parts of the partition you are trying to rescue data from are corrupt, then ddrescue (unlike dd) skips over it and gets out all the data that is uncorrupted!
Install ddrescue using
$sudo apt-get install ddrescue
Make sure you have a partition with more disk space that the entire partition you are trying to retrieve data from. Yes, that includes occupied AND free space on the partition you are trying to retrieve data from.
Rescue data using:
$dd_rescue /dev/hda1 /some/dir/drive-backup.img
Where you might have to replace /dev/hda1 with the partition you are trying to rescue data from, and /some/dir/ should have more free space than the entire /dev/hda1 partition.
This creates a drive image. You can mount it as a loop device. Do the following to do just that:
sudo touch /dev/loop1
sudo losetup /dev/loop1 /some/dir/drive-backup.img
–If you get an ioctl error, run “$sudo modprobe loop”, and run the prior command again
sudo mount -t ext3 /dev/loop1 /media/drive-backup
(replace ext3 with the filesystem type of your old partition)
Now you can browse /dev/loop1 and copy out all your data. If you use an external USB drive to backup the image to, you can take the image with you 🙂
Thanks are due to Dan Martin who posted this at the ubuntu-users mailing list a few weeks ago.