Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

So I have a hard drive that is failing. I want to erase the data on it before sending it for replacement. I'm trying to use dd if=/dev/zero of=/dev/sdXX, but it stops at the first write error. How can I overwrite the drive with zeros, ignoring write errors? conv=noerror seems to only affect the input file.

share|improve this question
    
There is a bug report in the Debian database about this behavior, but it seems like it's not implemented yet. –  Bobby Dec 15 '10 at 12:09
    
Does badblocks also stop on errors? Perhaps you could do a destructive write with that? –  oKtosiTe Dec 15 '10 at 13:57
    
I now also ran destructive badblocks to be sure how much bad blocks are there before I return the disk on Monday. It also erased the disk successfully, but it took nearly 50 hours. –  TestUser16418 Dec 19 '10 at 19:30
add comment

5 Answers

up vote 9 down vote accepted

try ddrescue instead of dd - it tries harder with errors

share|improve this answer
    
ddrescue successfully erased the entire disk, ignoring the write errors. Thank you very much. –  TestUser16418 Dec 15 '10 at 22:41
add comment

If you are just looking to wipe the drive try dban

From the site:

Darik's Boot and Nuke ("DBAN") is a self-contained boot disk that securely wipes the hard disks of most computers. DBAN will automatically and completely delete the contents of any hard disk that it can detect, which makes it an appropriate utility for bulk or emergency data destruction.

share|improve this answer
    
I was going to suggest this. –  qroberts Dec 15 '10 at 17:23
add comment

Parameters I used with ddrescue to erase drive /dev/sdb (filled with zeros from /dev/zero) and log output into file log.txt:

ddrescue --force /dev/zero /dev/sdb log.txt
share|improve this answer
add comment

For the record, dd also has an option conv=noerror to skip errors. If you had errors on an input file (when not using /dev/zero, you'd want to use conv=noerror,notrunc or conv=noerror,sync to prevent dd from truncating the output file where errors exist on the input file. For your query, you might try this command instead:

dd if=/dev/zero of=/dev/sdXX conv=noerror  

To speed up the process, and potentially avoid the drive dying in mid stride, you might also try increasing the byte size from the default 512 (which makes dd read sector-by-sector, which is slow) to something larger such as 4K (which is eight times as large):

dd if=/dev/zero of=/dev/sdXX bs=4K conv=noerror  

Note: With a larger byte size, skipped errors may leave sections of readable data slightly-less than the byte size you choose, but it's still unlikely that anyone would be able to get anything from those sections after the entire disk has been run through the process.

Besides that, I'm sure hard drive manufacturers properly dispose of hard drives that get returned for warranty replacement, in case the drive does fail before you were able to fully complete the overwrite process.

share|improve this answer
    
man dd shows "noerror" means "continue after read errors" –  Kevin Smyth Jan 18 at 20:43
add comment

Definitely not a power-user solution, but if the write errors are rare, you might just want to continue manually after their occurence.

You could theoretically script something to do that automatically, but it's not that trivial, and I'd rather write a tool to do the trick than bother with scripting dd..

   seek=BLOCKS
          skip BLOCKS obs-sized blocks at start of output
share|improve this answer
add comment

protected by Journeyman Geek Jan 7 '13 at 14:45

Thank you for your interest in this question. Because it has attracted low-quality answers, posting an answer now requires 10 reputation on this site.

Would you like to answer one of these unanswered questions instead?

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