How do I fix an Input/Output error using dd?
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
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.