How do I fix an Input/Output error using dd?

106,091

Solution 1

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

Solution 2

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.

Solution 3

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
Share:
106,091

Related videos on Youtube

Erazer
Author by

Erazer

i'm just new guy of here, trying helping other's what i know! =')

Updated on September 18, 2022

Comments

  • Erazer
    Erazer over 1 year

    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"?

  • Erazer
    Erazer about 11 years
    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..
  • Dennis Kaarsemaker
    Dennis Kaarsemaker about 11 years
    So your backup is on the same drive as the drive you're bcaking up?! boggles
  • Erazer
    Erazer about 11 years
    well same drive yes but not on same partition. well i'm little bit stupid :'( backup its not imporant at all