View previous topic :: View next topic |
Author |
Message |
br14n n00b
Joined: 10 Oct 2002 Posts: 43
|
Posted: Thu May 22, 2003 6:51 pm Post subject: short dd if=/dev/urandom reads |
|
|
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 |
|
|
dma Guru
Joined: 31 Jan 2003 Posts: 437 Location: Charlotte, NC, USA
|
Posted: Fri May 23, 2003 3:03 am Post subject: |
|
|
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 |
|
|
oldfrog n00b
Joined: 25 Oct 2002 Posts: 9
|
Posted: Wed Jul 16, 2003 3:17 am Post subject: It is a lowlatency bug in random.c |
|
|
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 |
|
|
watersb Apprentice
Joined: 04 Sep 2002 Posts: 297 Location: take a left turn in Tesuque
|
Posted: Sun Jul 27, 2003 1:23 pm Post subject: |
|
|
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 |
|
|
|