Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
short dd if=/dev/urandom reads
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Networking & Security
View previous topic :: View next topic  
Author Message
br14n
n00b
n00b


Joined: 10 Oct 2002
Posts: 43

PostPosted: Thu May 22, 2003 6:51 pm    Post subject: short dd if=/dev/urandom reads Reply with quote

I typically use dd to fill up files with random stuff from /dev/urandom when I'm making an encrypted loopback container. But lately I have been getting crazy results.

dd if=/dev/urandom of=x bs=1M count=256; ls -l x
0+256 records in
0+256 records out
-rw------- 1 root root 3.8M May 22 13:45 x

I seem to get random sizes instead of what I ask for. /dev/zero works ok. I'm using 2.4.20-gentoo-r4. TIA for ideas.
Back to top
View user's profile Send private message
dma
Guru
Guru


Joined: 31 Jan 2003
Posts: 437
Location: Charlotte, NC, USA

PostPosted: Fri May 23, 2003 3:03 am    Post subject: Reply with quote

Same here.

Code:
dma@laureate:~$ dd if=/dev/urandom of=x bs=1024 count=10000; ls -l x
9982+18 records in
9982+18 records out
-rw-r--r--    1 dma      users    10234238 May 22 22:50 x

dma@laureate:~$ dd if=/dev/urandom of=x bs=1024 count=10000; ls -l x
9977+23 records in
9977+23 records out
-rw-r--r--    1 dma      users    10233718 May 22 22:50 x

dma@laureate:~$ dd if=/dev/urandom of=x bs=1024 count=10000; ls -l x
9982+18 records in
9982+18 records out
-rw-r--r--    1 dma      users    10234578 May 22 22:51 x

And...
Code:
dma@laureate:~$ dd if=/dev/urandom of=x bs=1M count=1; ls -l x
0+1 records in
0+1 records out
-rw-r--r--    1 dma      users         290 May 22 22:59 x


Code:
BLOCKSIZE=1      #  I/O with /dev/urandom requires unit block size,
                 #+ otherwise you get weird results.
...
   dd if=/dev/zero of=$file bs=$BLOCKSIZE count=$flength
...


So it would seem that a block size of ONE BYTE does it.

Any block size above 8 will screw it up. Dunno about stuff below that.
Back to top
View user's profile Send private message
oldfrog
n00b
n00b


Joined: 25 Oct 2002
Posts: 9

PostPosted: Wed Jul 16, 2003 3:17 am    Post subject: It is a lowlatency bug in random.c Reply with quote

It is a lowlatency bug in random.c in your kernel sources. replace /usr/src/linux/drivers/char/random.c with one from newer kernel sources. I used the one from 2.4.21 taken from kernel.org After replacing random.c recompile your kernel.
Back to top
View user's profile Send private message
watersb
Apprentice
Apprentice


Joined: 04 Sep 2002
Posts: 297
Location: take a left turn in Tesuque

PostPosted: Sun Jul 27, 2003 1:23 pm    Post subject: Reply with quote

Hey, that's a good fix!

It could also be that you are running out of entropy -- there isn't enough randomness in the system to sustain the output.

To intialize an encrypted loop, this is what I do instead:
Code:

# openssl rand out=/dev/hdaX notrunc


This will spew random bytes until the partition is full. Much faster, and is apparently reasonably random...
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Networking & Security All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum