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, say you've completed a full pass of:

dd if=/dev/zero of=/dev/sdX bs=1M

Then, you'd like to make sure the destination has been really zeroed out (ignoring the confirmation messages from dd and not just polling the start or the end of the device). Assuming, that you'd have to read through the whole disk - I'd use this:

dd if=/dev/sdX bs=1M | grep -P '[^\x00]'

However, as this works with piping the stdout eventually this falls out with an error saying that the operation ran out of memory. So, it's of no use.

Of course, creating a whole image of the entire disk and saving it - is not an option. But, perhaps, doing that while somehow being able to skip 0x00 on the fly - that'd be one of the solutions..

Ideas?

share|improve this question
add comment

1 Answer

up vote 5 down vote accepted

There is a device, /dev/zero on a linux system that always gives zero when read.

So, how about comparing your hard drive with this device:

cmp /dev/sdX /dev/zero

If all is well with zero-ing out your hard drive it will terminate with:

cmp: EOF on /dev/sdb

telling you that the two files are the same until it got to the end of the hard drive. If there is a non zero bit on the hard drive cmp will tell you where it is in the file.

If you hav the pv package installed then

pv /dev/sdX | cmp /dev/zero

will do the same thing with a progress bar to keep you amused while it ckecks your drive (the EOF will now be on - rather than sdX though).

share|improve this answer
    
Great suggestion, I will try that out (hopefully without out of memory errors as of this time), thank you! –  XXL Jan 7 '12 at 18:23
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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