Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I recently wiped my hard disk with a fresh Ubuntu installation. I'm planning to use Testdisk to recover the files.

However, since I do not have prior experience, I feel it would be safer if I could keep an image of the hard drive as well. That way, I can work on the image to avoid wrecking the original drive even more.

I have two questions:

1) Could you suggest a tool for the same?

2) Since I need the image for recovery, I don't want to overwrite the hard disk anymore than it already has been. Hence, could you comment if the tool would affect the hard drive in any way (if it is run via a usb)?

share|improve this question
2  
Take a look at the answer to this askubuntu.com/questions/296109/… it may point you in the right direction. Note: I'ts going to take a long time :) –  SimplySimon Jun 26 '13 at 19:42

2 Answers 2

up vote 2 down vote accepted

You need to have some things prepared first:

  • your original hard-drive from where you will read all the bits (you have this one, obviously);
  • a separate hard-drive where you will write the backup - this one needs to be already partitioned & formatted and must have ENOUGH free space to host your backup file (if your original hard-drive has 80 GB, you must have at least 80 GB free on a partition of the backup hard-drive to create the backup);
  • a Linux LiveCD/LiveDVD/LiveUSB to boot from - it must have the "dd" utility. I guess using the CD/DVD/USB you already used to install Ubuntu should be ok.

Steps:

1) make sure both hard-drives are connected to the computer you will be using;

2) boot from the LiveCD/LiveDVD/LiveUSB and check what drive is what - let's say from now on that original drive is sda and backup drive is sdb. Let's also say the backup drive has only 1 partition, sdb1.

3) make sure nothing from sda is mounted;

4) make sure the backup partition (/dev/sdb1) is mounted (let's say to /media/sdb1);

5) you need to run from a terminal the "dd" command like this (it means: "copy bit-by-bit the whole sda hard-drive to file backup.img in /media/sdb1 using a block-size of 1 MB"):

dd if=/dev/sda of=/media/sdb1/backup.img bs=1M

Please know that, depending on your original drive size, step 5) will take less or more (or a lot of) time.

Good luck and let us know what happens!

Note: you can always restore from the backup file by using:

dd if=/media/sdb1/backup.img of=/dev/sda bs=1M

Again, please make sure to check what drive is what - sdb is the backup drive, sda is the drive where the backup will be restored.

share|improve this answer
    
Thanks a lot for the detailed instructions! I have a quick question - does the block size matter while using dd keeping in mind that I have a 2TB hdd? I'll copy the disk and attempt recovery using photorec tomorrow and post the results here. (Fingers crossed) –  Saurabh Agarwal Jun 26 '13 at 21:16
    
Yes, the block size matters, but unfortunately there is only one way to determine the optimal block size, and that's a benchmark (with various block sizes and choosing the value that gives the best times) on the specific system/drive combination. Various opinions say the value should be definitely a power of 2. For modern hard drives, my guess is it should be multiple of 1 MB (but no more than the hard drive cache, I think). –  Fane Jun 27 '13 at 9:03

I heard dd can do it: link -- but I never used it

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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