為了要製造一個大檔,所以下了這個指令:

SHELL> dd if=/dev/random of=random1g.1 bs=1M count=1024

沒想到,等了 10 分鐘還沒有結束,ls 一看,random1g.1 才數百 K 大而已,火大只好退而求其次用 /dev/zero 做。不過疑問還是存在:為什麼 /dev/random 這麼誇張地慢?

早上改用 /dev/urandom 試,速度快很多。雖然還是很慢,但已經可以在合理時間完成任務。查了一下 Google,找到這篇《Re: [Nottingham] Very slow dd if=/dev/random》:

/dev/random will block until it has gathered enough entropy to give you
some more randomness. If it is on the same machine, try moving your mouse
or using the keyboard to generate some more.

An experiment (under X) will demonstrate it. Open an xterm and run 'od -c
/dev/random'. It should work for a few seconds and then stop. Whilst
it's stopped, moved the mouse or open another window. It should start
moving again.

If you don't want blocking to occurr for 'truer' randomness, try using the
device '/dev/urandom' 

所以,套句同事的話:在用 /dev/random/dev/urandom 的時候,沒事請亂敲鍵盤一下。XD

測試環境:CentOS 5.4 in VMware。