Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

A few nights ago I have created a backup of my data on an external 500 GB NTFS USB hard drive. I have then formatted my computer, reinstalled Ubuntu and started transferring back the data from the external HDD.

Unfortunately some files have became corrupted and Ubuntu is unable to copy them over. The same issue happens if I login using Windows 7.

Disk Utility detects with SMART that there are "a few bad sectors".

Some of files are perfectly intact, but other files cannot be accessed (nor read, copied...) although they are displayed within nautilus and show the correct file size.

Is there anything I can do to recover this data? I have thought of using TestDisk but this utility seems more useful for repairing lost partitions or deleted files.

I have also thought of using ddrescue so I could at least have a low level copy of the disk but I am not sure what use to make of it in order to recover the data!!!

share|improve this question

If a drive has unreadable sectors one of the choices you have is to make an image of it with dd forcing it to ignore the damaged sectors and then mount that image to read the useful data.

Create a image of the drive

Use the command sudo fdisk -l to identify your USB disk, note his device path, it should look something like /dev/sd[*], where [*] is a letter representing your USB drive.

When you are sure about the path to the drive you want to copy you can use dd to make a image of it and use the options to keep on reading after failing to read data

dd if=/dev/hd[*] of=/foo_path/foo_image conv=noerror,sync

This will read the device /dev/sd[*], output it to /foo_path/foo_image and ignore read errors. /foo_path/foo_image should not be on the same disk you are reading.

So, lets say you used sudo fdisk -l and you found that your USB drive is /dev/sdb, you can then use any of those commands to make an image just by replacing /dev/hd[*] with /dev/sdb.

Mouting the image file to read the data

You need to create a mount point, lets call it /mnt/ddimage

sudo mkdir /mnt/ddimage

Now mount the image you just created to it

mount /foo_path/foo_image /mnt/ddimage -o loop

You should now be able to read any useful data from the cloned drive image.

share|improve this answer
Thank you very much, I would love to try that straight away but I have got another problem. The external damaged drive is 500GB and the maximum space I got on my PC is 500GB. What I will do now is to first resize the damaged drive partition because the data contained is "only" 100GB and then I should be able to create an image of this smaller partition. I will keep you posted with the events (hopefully good) – Martin Jun 4 '12 at 22:36
That is going to be a problem, is the USB disk space divided in any way? Do you have any partitions on it, or just a big one? – Bruno Pereira Jun 4 '12 at 22:39
it's a one entire partition, I could maybe try to resize the partition – Martin Jun 4 '12 at 22:51
I am scared about any bad sectors messing up the resize :/ – Bruno Pereira Jun 4 '12 at 22:56
Let me know what the result is, anyways a dd image is the way to go on a damaged drive. – Bruno Pereira Jun 5 '12 at 20:38
up vote 3 down vote accepted

Problem solved! I know this is not related to Ubuntu but I think this could be useful for other people.

I have found out that Window's chkdsk could solve the problem, this is because Ubuntu doesn't support NTFS as well as Windows does. It has taken several hours/days to run the tasks (just Windows scandisk with all options activated) but in the end I have managed to recover 99.98% of the data.

share|improve this answer
Nice man. Lost data always sucks. Good job. – Bruno Pereira Jun 10 '12 at 9:20
you did the ntfschk c: /r i suppose ? yeah it takes forever but it is known to remap bad data clusters well.. – marc-andre benoit Dec 22 '13 at 2:19

Instead using dd you should use a tool which handles errors better instead of filling them with zeros. I ran into many timeouts which makes the process really long and tedious. The alternative is ddrescue which retries failed sectors and also is a little bit faster in skipping bad sectors from my experience.

Install (ubuntu)

sudo apt-get install gddrescue

Create the image

 sudo ddrescue -d -r3 /dev/sda1 test.img test.logfile

This will create an image in the current dir named test.img of the disk /dev/sda1. You can of course backup the full drive instead of a single partition. (The r parameter tells it to retry failed sectors three times - don't forget the logfile, otherwise this will not work) ddrescue also allows you to abort/resume the process which is really nice.

Mounting the image file

Create a folder where you want to mount the image and mount the image

sudo mkdir /mnt/mybackup
mount test.img /mnt/mybackup -o loop

Check out the following for more information:

share|improve this answer

Your Answer


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.