3 ms·
Zeros are far more efficient and much faster to generate. Not sure why some have downvoted me. It's easy to verify. time dd if=/dev/zero of=file1.bin bs=1
by w8rbt 9y ago
Zeros are far more efficient and much faster to generate.
Not sure why some have downvoted me. It's easy to verify.
time dd if=/dev/zero of=file1.bin bs=1M count=600
600+0 records in
600+0 records out
629145600 bytes (629 MB) copied, 1.57948 s, 398 MB/s
real 0m1.651s
user 0m0.004s
sys 0m0.688s
time dd if=/dev/urandom of=file2.bin bs=1M count=600
600+0 records in
600+0 records out
629145600 bytes (629 MB) copied, 37.7828 s, 16.7 MB/s
real 0m37.786s
user 0m0.004s
sys 0m37.784s
- sliken 9y agoI didn't downvote, but /dev/urandom isn't a particularly large bottleneck for any recent machine. I've got a 4 generation old I5 (3570) dd of /dev/urandom gets 300MB/sec for me. SATA is only capable of twice that, so it's not a particularly large bottleneck. I do wonder what machine you used that's 20 times slower than a 4 generation old i5.
- rini17 9y agoI had similar problem with urandom, instead used openssl like this and it's fast enough: openssl enc -aes-256-cbc -in /dev/zero -out /dev/sdX
- sliken 9y agoInteresting. Looks like for newer kernels (newer than 4.8) that's about twice as fast. But for older kernels it's around 20 times as fast.
- gist 9y agoThanks for this. I actually spent a bit of time playing around and learning about dd based on the above. I found that on my machine it is also slower as well. Never really had a need to use dd even with many years of playing with Unix. This post appears to have the reason: https://superuser.com/questions/359599/why-is-my-dev-random-so-slow-when-using-dd https://superuser.com/questions/359599/why-is-my-dev-random-... (This raises the question of why using openssl (per other comment) makes it faster.)
- pstrateman 9y agoLinux kernels after 4.8 use chacha which is significantly faster than the previous implementation. (~250MB/s on my laptop).