Re: Create files with specific sizes?

Simon Valiquette
2004-12-14T18:54:56Z

SVisor a écrit :
>>
>> dd if=/dev/zero of=file1 bs=1k count=1024
>
> I wanted a file of garbage, not zeroes.
> So I tried: dd if=/dev/random of=file bs=1k count=1024
>

If you don't need encryption-level random numbers (just noise) you
can use urandom. It will also be much faster because it will continue
to send data even when his entropy pool will be exhausted.

dd if=/dev/urandom of=file bs=1k count=1024

> But to my suprise I got only a ~4k file. I know that dev/random may run
> out of values. But should dd not wait until there are enought of data?

That's exactly what it is supposed to do. Perhaps you tought
/dev/random could generate random numbers much faster. So when it's
entropy pool was exhausted after 4KB, you tought it stopped working.

By default, there is only a reserve of 4k of entropy in /dev/random.
Once exhausted, the others bits are *much* slower to get. I mean, in
the order of 1,000,000 times slower than urandom unless you have a
special device to generate random numbers in hardware.

You can see how much unused entropy you have with that:

cat /proc/sys/kernel/random/entropy_avail

Simon Valiquette