/bin/dd fails with big disks containing bad sectors
risner at stdio.com
Thu Jan 4 18:58:25 UTC 2007
I filed this PR (http://www.freebsd.org/cgi/query-pr.cgi?pr=kern/107443) and it was
suggested I bring the issue to this list.
If you have a defective disk larger than 2 gb with many bad sectors and attempt to use
dd under FreeBSD to duplicate the disk, the operation will fail with sectors being out of alignment.
dd bs=512 if=src of=dst conv=noerror,sync
Under Linux, this operation performs as expected.
There are faster methods of duplicating the disk (tools/recoverdisk is one.)
But sometimes you only have /bin/dd and a fixit disk. It isn't intuitive that
dd should fail in the way it is failing. The user (in this case me) doesn't expect
to have a disk improperly aligned.
I once resolved this issue several years ago with a patch to dd that is no long valid with
current sources. I recently resolved this issue by writing my own tiny dd program (code
is provided for curious people in the pr kern/107443) to properly copy the blocks.
>From what I can tell there are several requirements for this issue:
1) Disk > 2Gb
2) Disk has more than a few bad sectors.
3) Use dd to copy the disk.
It seems despite using "sync", dd is getting confused as to the input and output seek position.
They get out of sync with each other and all future output blocks are written earlier on the disk
than is required.
More information about the freebsd-hackers