top | item 22696737

(no title)

JensRex | 6 years ago

Per recent postings on HN about /dev/urandom, wouldn't it fine to use data from that, rather than bothering with AES output. /dev/urandom should be cryptographically safe.

discuss

order

jpdaigle|6 years ago

But how would you detect corruption in this case?

If you write random bytes then read them back, you have nothing to compare them to.

JoachimSchipper|6 years ago

tzs' solution is clever, but if you're planning to simply toss a bad drive (and don't particularly care which blocks are bad), something like

tee /dev/the/disk </dev/urandom | sha256sum

and

sha256sum /dev/the/disk

should also work fine.

tzs|6 years ago

Let b be the number of bytes per block.

1. Test N blocks of the disk, where N is small enough that you can keep a 128-bit hash of each block of random test data in memory for the duration of the test. You can use the hashes to verify that read data is correct.

2. Then test another Nb/8 blocks using the N blocks from #1 to store 128-bit hashes of the Nb/8 test blocks.

3. Then test N(1+b/8)/8 blocks, using the blocks from #1 and #2 to hold the hashes.

4. Then test N(1+b/8 + b/8^2)/8 blocks, using the blocks from #1 and #2 and #3 to hold the hashes.

...

(Maybe replace the 8's in that with 7's, and in each block of hashes include a hash of the 7 hashes, so you can check that hash blocks are reading back fine?)

JensRex|6 years ago

You're right, I don't know what I was thinking with that comment.

rini17|6 years ago

Have you ever tried dd'ing fom it? It is slooooow.