My hard drive just corrupted again (think it because i didn't eject via Windows because it wouldn't let me, no programs was using files on the drive either).

I've recovered some files but got a lot more to do, but I want to use the portable HDD again.

What can I use to create a image of the entire hard drive to capture its current state before I format it? I want to mount the image to a drive letter then carry on recovering lost data.

link|improve this question

36% accept rate
feedback

1 Answer

Get a nice livecd for a Linux distro (I like Gentoo) and bring up a shell with root privileges.

Somehow mount the hard disk partition you want to put your backup on. Partition names on Linux are on the form "/dev/sda1", where the 'a' becomes 'b' and 'c' for second and third hard drive and the number increases for additional partitions on the drive. Assuming sda1 and you use NTFS, you should type

mkdir hd ;
ntfs-3g /dev/sda1 hd/ ;

If you use FAT or something else Linux has kernel write support for, exchange ntfs-3g for mount.

To then copy the external drive to a file, you should type the following. I assume the external drive is the second hard drive alltogether, otherwise see (2). Then the name for the whole drive is "/dev/sdb".

dd bs=1M if=/dev/sdb of=hd/external-drive-backup.img ;

That will require a lot of disk space, so you might want to compress it a bit, for example like so in stead:

dd bs=1M if=/dev/sdb | xz -1 | dd of=hd/external-drive-backup.img.xz ;

Now you're done, you have a nice image of your whole external disk on you hard drive. You can then go on to repartition the disk with parted or somesuch and create new filesystems on it.

link|improve this answer
1  
Add a block size (-bs=1M) to the dd to make the command MUCH faster. – Chris Nava Jan 23 at 5:37
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.