Zero out flash memory
Posted on 2007-12-05
I work with embedded systems. Normally, when I need to wipe a hard drive clean, I use the Linux badblocks command to zero out the drive. badblocks -svw -b 512 -t 0x00 /dev/<device> does the trick by doing a destructive bad sector test using zeroes as the test pattern. I find that method to be faster than dd if=/dev/zero of=/dev/<device> bs=512, plus you get a progress indicator.
However, this method does not work on flash type media. I have tried USB sticks and most recently, SD cards. I wind up getting I/O errors about 3/4 of the way through, and the end of the card (as viewed in a hex editor) is not zeroed out at all (although the beginning is). This happens with different media from different brands. The failure is not always in the same spot, but they all fail.
SanDisk media in particular reacts very badly to this procedure. Once you get the I/O errors, it is simply a matter of making a filesystem on it to use it again in Linux. However, no Windows machine is ever able to work with the device ever again (not that I care that much about Windows, but it's odd).
Anwyay, my questions is this: Is there some kind of booger in the way the Linux kernel is working, or can you not do block level operations on flash media like that?
How would you do a low-level zero of all the data on a flash card?