19

Hi i'm Trying fixing my Windows 7 system with a broken harddrive, but it's still running.

I'm trying copy all data to a new drive to reinstall Windows 7. Drive called SQSERVICE.

I can't copy at all - see below:

$ sudo dd if=/dev/sdc1 of=/dev/sda1
dd: reading `/dev/sdc1': Input/output error
11233976+0 records in
11233976+0 records out
5751795712 bytes (5.8 GB) copied, 187.731 s, 30.6 MB/s

How to fix this "Input/output error"?

1
  • 1
    @Gertvddijk thanks to fix my spelling problem, i'm from netherlands still learning english well.
    – Erazer
    Feb 9 '13 at 13:36
20

You said it yourself: your disk is broken. You can try ddrescue, it may be able to work around the broken path. Beware though, that you will lose data.

Restoring from backup will be easier :)

The correct usage of ddrescue is as follows:

sudo apt-get install gddrescue
sudo ddrescue /dev/sdc1 /dev/sda1

or if you want to pipe stdout to the progess monitoring tool:

sudo ddrescue /dev/sdc1 /dev/sda1 | pv
3
  • yes i said that but restoring from backup it's on that drive.. and i this drive have only sector problem, well how can i use that command? im just newbie linux user..
    – Erazer
    Feb 9 '13 at 13:31
  • 3
    So your backup is on the same drive as the drive you're bcaking up?! boggles Feb 9 '13 at 13:44
  • 1
    well same drive yes but not on same partition. well i'm little bit stupid :'( backup its not imporant at all
    – Erazer
    Feb 9 '13 at 13:45
7

I don't know if this is useful to anyone, but if I found this page in my search, maybe it will help someone (other than the OP who hopefully solved his problem months ago).

ddrescue may be the best choice in this case, for data recovery (different from "fixing" the error/disk as the original question was worded), as Dennis suggested.

Alternatively, you could also mount the disk and copy the files. This is MUCH faster if there is lots of empty space, or if you only want some particular files. WARNING: done from a Linux machine, this loses all extended attributes, such as file permissions, so is a very bad choice for OS files, but tolerable for user files. Doing it from windows should preserve those, but might not handle errors smoothly, possibly making it go very slow.

Another option to actually "fix" the sectors, not just bypass them, is to reallocate the bad sectors. If you know the sector number (in your case, 11233976 assuming your block size in dd, and sector size are 512), just run this, and run again for each new bad sector you find:

hdparm –write-sector 11233976 –yes-i-know-what-i-am-doing /dev/sdb

WARNING: This will destroy the data on that sector. So be sure you really do know what you're doing. If this sector can't be read, overwriting it will stop the errors, but it will mean that sector will contain garbage, possibly corrupting an important file.

See this for more info: http://www.sjvs.nl/forcing-a-hard-disk-to-reallocate-bad-sectors/

And if your disk has a large number (thousands perhaps) of bad sectors (either seen as Current_Pending_Sector, Offline_Uncorrectable or Reallocated_Sector_Ct), or if it's new and still on warranty, or if the number consistently goes up over time, then you should replace the disk anyway. Don't let them tell you that reallocating fixes the disk. It only fixes the known bad sectors and consumes the sectors reserved for reallocation. If the disk is prone to developing more bad sectors, the problem will just keep coming back, each time corrupting some data.

5

While some parts of disk are broken, you are still able to copy good parts of disk.

$ dd --help
...
 noerror   continue after read errors
...
sudo dd if=/dev/sdc1 of=/dev/sda1 conv=noerror
0

I had a drive with IO-Errors and on top of that the drive disconnected itself after a couple of minutes read, but then came back after a couple of seconds, that's also why i use disk/by-uuid since the device name changed after this happened. I extended Dennis' Answer and this one to run indefinitely:

#!/bin/bash
while [ true ]
do
    echo "start ddrescue"
    ddrescue -O  --retry-passes=3 /dev/disk/by-uuid/<uuid> /media/<other-disk>/data.img  /media/<other-disk>data_ddrescue_map
    echo "ddrescue end, sleep 30"
    sleep 30
done
    

This will use ddrescue with an map file, that way you can restart the program and ddrescue will continue where it was before. It will recover the data to an .img-File.

The -O Parameter means "reopen input file after every read error".

Every time it fails, the script sleeps 30 seconds and then tries again. After nearly a Day i got to 99% Rescued, after that it stalled. I let the drive cool down and tried again, then i got to 100%.

Warning: The script will run forever, unless you terminate it yourself, wenn your are happy with the results.

With these commands you can mount the created image to browse the files:

sudo mkdir /media/data-image
sudo mount -o loop,ro /media/<other-disk>/data.img /media/data-image

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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