2

I have an old 320 GB laptop hard drive that I'm getting ready to sell (or donate). To prepare it, I'm using dd to write one pass of random data, then one pass of zeros:

dd if=/dev/urandom of=/dev/sdb
dd if=/dev/zero of=/dev/sdb

In both cases, it gets almost to the end of the disk and then fails with:

dd: error writing '/dev/sdb': Input/output error

Using od /dev/sdb to verify the zero write, I see:

0000000 000000 000000 000000 000000 000000 000000 000000 000000
*
4520565200000 150636 113232 106346 032136 015617 116562 007414 032774
4520565200020 122317 125101 056551 105476 117454 153132 054340 177042
4520565200040 036343 143567 116241 045303 146340 016110 034246 150020
    ...snip...
4520565257720 100673 143151 002110 144654 065605 120456 070460 106051
4520565257740 032350 125132 022255 032441 074515 142667 117313 127115
4520565257760 035414 166734 072432 032526 061274 137236 117436 156032
4520565260000

...which indicates to me that the zeroing mostly succeeded, but the last (4520565260000 - 4520565200000 = 60000 octal) 24 kB of the disk still has non-zero (and likely non-random) data on it.

This disk is attached via an external USB-to-SATA adapter. I tried it under both Ubuntu and Cygwin, and saw the same result in both cases.

Is there some option I should be passing to dd that would help, or is this the disk just physically bad? I've never had an issue with it, and it never showed any bad sectors when it used to hold an NTFS filesystem.

0

When using dd I have always used the following:

dd if=<source> conv=sync,noerror of=<destination>

I think you simply need to add the conv=sync,noerror option so it will continue even if it detects an error. It will simply write 0's for anywhere it can not read.

|improve this answer|||||
  • I believe conv= applies to the input file only, correct? In this case the input file is /dev/zero, which I would hope could always read without error. ;) – smitelli Apr 6 '15 at 15:04
  • @smitelli True but I have used this on a drive that did have a lot of bad sectors on it and was able to blank the whole drive. TBH I can't remember if I tried it with out the 'conv=' beforehand though. – Devan Apr 6 '15 at 17:49

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.