10

The question have been asked in here http://www.gossamer-threads.com/lists/linux/kernel/1210167 but I don't see an answer.

AFAIK /proc/sys/kernel/random/entropy_avail should return the size of available entropy but should not consume it. At least I don't see any reason for that.

However, I have been noticing the same thing as OP for at least a year and now I executed in quick succession

% cat /proc/sys/kernel/random/entropy_avail 
3918
% cat /proc/sys/kernel/random/entropy_avail
3447
% cat /proc/sys/kernel/random/entropy_avail
2878
% cat /proc/sys/kernel/random/entropy_avail
2377
% cat /proc/sys/kernel/random/entropy_avail
1789
% cat /proc/sys/kernel/random/entropy_avail
1184
% cat /proc/sys/kernel/random/entropy_avail
577
% cat /proc/sys/kernel/random/entropy_avail
161
% cat /proc/sys/kernel/random/entropy_avail
133
% cat /proc/sys/kernel/random/entropy_avail
171

a while later I did the same with the same result, so I'm pretty sure the depletion of entropy is caused by the cat command.

Can anyone explain why this happens?

Jan Matějka
  • 1,880
  • 1
  • 14
  • 31
  • 4
    The question you post have the answer. It's `cat` consuming the entropy, not reading the file. – J-16 SDiZ Nov 01 '12 at 03:06
  • D'oh. I have read just half of the comment and guessed the rest won't contain the answer so I skipped it. – Jan Matějka Nov 01 '12 at 03:37
  • 1
    You can use `python -c "$(echo -e "import time\nwhile True:\n time.sleep(1)\n print open('/proc/sys/kernel/random/entropy_avail', 'rb').read(),")"`. I'd love to write it in multiple lines as it should be, but can't find a way to format the comment. This will start just one process. – Doncho Gunchev Nov 29 '13 at 21:51

1 Answers1

11

Found an answer in here http://blog.flameeyes.eu/2011/03/entropy-broken

Starting a process consumes entropy

Jan Matějka
  • 1,880
  • 1
  • 14
  • 31