I recently experimented with different methods of disk randomization to find what would get the job done fastest. The openssl
random number generator with AES in counter mode was said to be pretty fast, so I tried piping its output to dd
(to limit the total number of output bytes and to optimize for disk sector size). See here for the invocation. Using this technique, I was able to write out to the raw disk at a sustained rate around 30 MB/s.
Using the shred
utility alone (in single-pass mode, using /dev/urandom
as the RNG), the sustained write rate was well under 10 MB/s.
However, using the shred
with the openssl
generator, I was able to sustain write speeds of about 1.5 GB/s:
mkfifo rand
openssl enc -aes-256-ctr -pass pass:"$(dd if=/dev/urandom bs=128 count=1 2>/dev/null | base64)" -nosalt </dev/zero >rand &
shred --verbose --random-source=rand -n1 /dev/sda
rm rand
I hadn't observed speeds anywhere near this rate (either in terms of random number streaming or raw IO speed) before this point, so I'm wondering if this means that shred
is somehow taking (insecure) shortcuts. I realize that shred
itself is probably only using the given random number generator to seed its own, faster PRNG, but is AES actually that much faster than /dev/urandom
? Or is something else happening under the hood?