public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* dd if=/dev/random of=data.bin bs=512 count=1
@ 2009-05-17 15:22 Jon Grant
  2009-05-17 16:01 ` KOSAKI Motohiro
  2009-05-17 16:27 ` Bernd Eckenfels
  0 siblings, 2 replies; 7+ messages in thread
From: Jon Grant @ 2009-05-17 15:22 UTC (permalink / raw)
  To: linux-kernel

Hello

Issuing this command, I expected to get a file 4096 bytes in size.
Could someone let me know if I have missed something..? Or is there a
problem with using /dev/random this way?

if I have a count=10 it hangs forever (several hours).

Changing to use /dev/urandom and it generates the file ok.

Please include my email address in replies,  as I'm not a member of this list.

Best regards, Jon

$ dd if=/dev/random of=data.bin bs=512 count=1
0+1 records in
0+1 records out
8 bytes (8 B) copied, 4.47366 s, 0.0 kB/s

$ dd --version
dd (coreutils) 6.10

$ uname -a
Linux ubuntu 2.6.28-11-generic #42-Ubuntu SMP Fri Apr 17 01:57:59 UTC
2009 i686 GNU/Linux

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: dd if=/dev/random of=data.bin bs=512 count=1
  2009-05-17 15:22 dd if=/dev/random of=data.bin bs=512 count=1 Jon Grant
@ 2009-05-17 16:01 ` KOSAKI Motohiro
  2009-05-23 19:12   ` Jon
  2009-05-17 16:27 ` Bernd Eckenfels
  1 sibling, 1 reply; 7+ messages in thread
From: KOSAKI Motohiro @ 2009-05-17 16:01 UTC (permalink / raw)
  To: Jon Grant; +Cc: linux-kernel

> Hello
>
> Issuing this command, I expected to get a file 4096 bytes in size.
> Could someone let me know if I have missed something..? Or is there a
> problem with using /dev/random this way?
>
> if I have a count=10 it hangs forever (several hours).
>
> Changing to use /dev/urandom and it generates the file ok.

you already have the answer. /dev/random might blocked, /dev/urandom doesn't.


> Please include my email address in replies,  as I'm not a member of this list.
>
> Best regards, Jon
>
> $ dd if=/dev/random of=data.bin bs=512 count=1
> 0+1 records in
> 0+1 records out
> 8 bytes (8 B) copied, 4.47366 s, 0.0 kB/s
>
> $ dd --version
> dd (coreutils) 6.10
>
> $ uname -a
> Linux ubuntu 2.6.28-11-generic #42-Ubuntu SMP Fri Apr 17 01:57:59 UTC
> 2009 i686 GNU/Linux
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/
>

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: dd if=/dev/random of=data.bin bs=512 count=1
  2009-05-17 15:22 dd if=/dev/random of=data.bin bs=512 count=1 Jon Grant
  2009-05-17 16:01 ` KOSAKI Motohiro
@ 2009-05-17 16:27 ` Bernd Eckenfels
  1 sibling, 0 replies; 7+ messages in thread
From: Bernd Eckenfels @ 2009-05-17 16:27 UTC (permalink / raw)
  To: linux-kernel

In article <19ac3f7a0905170822q28255239nea01b56d52e3ddf8@mail.gmail.com> you wrote:
> Issuing this command, I expected to get a file 4096 bytes in size.

one time 512 is 512 not 4096.

> if I have a count=10 it hangs forever (several hours).

It depends on your harware and usage type (mouse atached?) how much entropy
is generated and filled into the pool.  If you drain it, it will hang for
/dev/random and generate PRNG data with /dev/urandom. 

You should think carefully about sucking too many random bytes from /dev/random.

> $ dd if=/dev/random of=data.bin bs=512 count=1
> 0+1 records in
> 0+1 records out
> 8 bytes (8 B) copied, 4.47366 s, 0.0 kB/s

I am not sure why you only get 8bytes here, but I would suggest to use "bs=1
count=256" anyway.

Gruss
Bernd

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: dd if=/dev/random of=data.bin bs=512 count=1
  2009-05-17 16:01 ` KOSAKI Motohiro
@ 2009-05-23 19:12   ` Jon
  2009-05-23 19:20     ` Samuel Thibault
                       ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Jon @ 2009-05-23 19:12 UTC (permalink / raw)
  To: KOSAKI Motohiro; +Cc: linux-kernel

Hello KOSAKI,

Thank you for your reply.

KOSAKI Motohiro wrote:
>> Hello
>>
>> Issuing this command, I expected to get a file 4096 bytes in size.
>> Could someone let me know if I have missed something..? Or is there a
>> problem with using /dev/random this way?
>>
>> if I have a count=10 it hangs forever (several hours).
>>
>> Changing to use /dev/urandom and it generates the file ok.
> 
> you already have the answer. /dev/random might blocked, /dev/urandom doesn't.

Is this a "feature" of /dev/random ? ..it does not seem very useful to 
have it able to block for so long.

Please include my email address in replies,  as I'm not a member of this 
list.

Best regards, Jon

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: dd if=/dev/random of=data.bin bs=512 count=1
  2009-05-23 19:12   ` Jon
@ 2009-05-23 19:20     ` Samuel Thibault
  2009-05-23 19:38     ` Matt Mackall
  2009-05-24  0:59     ` Bill Davidsen
  2 siblings, 0 replies; 7+ messages in thread
From: Samuel Thibault @ 2009-05-23 19:20 UTC (permalink / raw)
  To: Jon; +Cc: KOSAKI Motohiro, linux-kernel

Jon, le Sat 23 May 2009 20:12:59 +0100, a écrit :
> KOSAKI Motohiro wrote:
> >>Issuing this command, I expected to get a file 4096 bytes in size.
> >>Could someone let me know if I have missed something..? Or is there a
> >>problem with using /dev/random this way?
> >>
> >>if I have a count=10 it hangs forever (several hours).
> >>
> >>Changing to use /dev/urandom and it generates the file ok.
> >
> >you already have the answer. /dev/random might blocked, /dev/urandom 
> >doesn't.
> 
> Is this a "feature" of /dev/random ?

It is, as opposed to urandom

> ..it does not seem very useful to have it able to block for so long.

The feature is about to wait for random data to be available, not only
pseudo-random data.

Samuel

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: dd if=/dev/random of=data.bin bs=512 count=1
  2009-05-23 19:12   ` Jon
  2009-05-23 19:20     ` Samuel Thibault
@ 2009-05-23 19:38     ` Matt Mackall
  2009-05-24  0:59     ` Bill Davidsen
  2 siblings, 0 replies; 7+ messages in thread
From: Matt Mackall @ 2009-05-23 19:38 UTC (permalink / raw)
  To: Jon; +Cc: KOSAKI Motohiro, linux-kernel

On Sat, 2009-05-23 at 20:12 +0100, Jon wrote:
> Hello KOSAKI,
> 
> Thank you for your reply.
> 
> KOSAKI Motohiro wrote:
> >> Hello
> >>
> >> Issuing this command, I expected to get a file 4096 bytes in size.
> >> Could someone let me know if I have missed something..? Or is there a
> >> problem with using /dev/random this way?
> >>
> >> if I have a count=10 it hangs forever (several hours).
> >>
> >> Changing to use /dev/urandom and it generates the file ok.
> > 
> > you already have the answer. /dev/random might blocked, /dev/urandom doesn't.
> 
> Is this a "feature" of /dev/random ? ..it does not seem very useful to 
> have it able to block for so long.

Yes. The theory is that it will be secure even in the event of a
catastrophic failure of the cryptographic compression function. But
don't worry about that; use /dev/urandom.

-- 
http://selenic.com : development and support for Mercurial and Linux



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: dd if=/dev/random of=data.bin bs=512 count=1
  2009-05-23 19:12   ` Jon
  2009-05-23 19:20     ` Samuel Thibault
  2009-05-23 19:38     ` Matt Mackall
@ 2009-05-24  0:59     ` Bill Davidsen
  2 siblings, 0 replies; 7+ messages in thread
From: Bill Davidsen @ 2009-05-24  0:59 UTC (permalink / raw)
  To: Jon; +Cc: KOSAKI Motohiro, linux-kernel

Jon wrote:
> Hello KOSAKI,
> 
> Thank you for your reply.
> 
> KOSAKI Motohiro wrote:
>>> Hello
>>>
>>> Issuing this command, I expected to get a file 4096 bytes in size.
>>> Could someone let me know if I have missed something..? Or is there a
>>> problem with using /dev/random this way?
>>>
>>> if I have a count=10 it hangs forever (several hours).
>>>
>>> Changing to use /dev/urandom and it generates the file ok.
>>
>> you already have the answer. /dev/random might blocked, /dev/urandom 
>> doesn't.
> 
> Is this a "feature" of /dev/random ? ..it does not seem very useful to 
> have it able to block for so long.
> 
Of course. /dev/random generates better random numbers (in the sense of less 
predictable), while /dev/urandom gives you some pseudo-random bits, which mat or 
may not be appropriate for your task. For timing disk speed /dev/zero is faster 
and less overhead.

> Please include my email address in replies,  as I'm not a member of this 
> list.
> 
> Best regards, Jon


-- 
Bill Davidsen <davidsen@tmr.com>
   "We have more to fear from the bungling of the incompetent than from
the machinations of the wicked."  - from Slashdot

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2009-05-24  0:59 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-05-17 15:22 dd if=/dev/random of=data.bin bs=512 count=1 Jon Grant
2009-05-17 16:01 ` KOSAKI Motohiro
2009-05-23 19:12   ` Jon
2009-05-23 19:20     ` Samuel Thibault
2009-05-23 19:38     ` Matt Mackall
2009-05-24  0:59     ` Bill Davidsen
2009-05-17 16:27 ` Bernd Eckenfels

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox