; /dev/random: uses an entropy pool of 4096 bits (512 Bytes) to generate random data and stops when the pool is exhausted until it get's (slowly) refilled. /dev/random is absolutely not designed for wiping entire HDD's, but rather to generate cryptographic keys (e.g. SSL/SSH).

+

{{ic|/dev/random}} uses an entropy pool of 4096 bits (512 Bytes) to generate random data and stops when the pool is exhausted until it gets (slowly) refilled. {{ic|/dev/random}} is designed for generating cryptographic keys (e.g. SSL/SSH), but it is impractical to use for wiping current HDD capacities: what makes disk wiping take so long is waiting for the system to [[Wikipedia:Hardware_random_number_generator#Using_observed_events|gather enough true entropy]]. In an entropy-starved situation (e.g. a remote server) this might never end, while doing search operations on large directories or moving the mouse in X can slowly refill the entropy pool.

−

+

−

The Kernel built-in RNG [[Wikipedia:/dev/random|/dev/random]] provides you the same quality random data you would use for keygeneration, but can be nearly impractical to use at least for wiping current HDD capacitys.

+

−

What makes disk wiping take so long with is to wait for it to [[Wikipedia:Hardware_random_number_generator#Using_observed_events|gather enough true entropy]].

+

−

In an entropy starved situation (e.g. remote server) this might never end while doing search operations on large directories or moving the mouse in X can slowly refill the entropy pool.

+

You can always compare {{ic|/proc/sys/kernel/random/entropy_avail}} against {{ic|/proc/sys/kernel/random/poolsize}} to keep an eye on your entropy pool.

You can always compare {{ic|/proc/sys/kernel/random/entropy_avail}} against {{ic|/proc/sys/kernel/random/poolsize}} to keep an eye on your entropy pool.

−

One can compare the actual available entropy {{ic|/proc/sys/kernel/random/entropy_avail}} against {{ic|/proc/sys/kernel/random/poolsize}} to keep an eye on the entropy pool. More information on the kernel RNG is available via {{ic|man 4 random}}.

+

While Linux kernel 2.4 did have writable {{ic|/proc}} entries for controlling the entropy pool size in newer kernels only {{ic|read_wakeup_threshold}} and {{ic|write_wakeup_threshold}} are writable. The pool size is now hardcoded in kernel line 275 of {{ic|/drivers/char/random.c}}:

−

+

−

The Kernels poolsize is {{ic|4096}} bit. (512 Byte)

+

−

+

−

While Linux kernel 2.4 did have writable {{ic|/proc}}-entries for controlling the entropy-poolsize in newer kernels only {{ic|read_wakeup_threshold}} and {{ic|write_wakeup_threshold}} are writable.

+

−

+

−

The pool size is now hardcoded in kernel line 275 of {{ic|/drivers/char/random.c}}

+

{{bc|/*

{{bc|/*

* Configuration information

* Configuration information

*/

*/

−

'''#define INPUT_POOL_WORDS 128'''

+

#define '''INPUT_POOL_WORDS 128'''

−

#define OUTPUT_POOL_WORDS '''32'''

+

#define '''OUTPUT_POOL_WORDS 32'''

−

#define SEC_XFER_SIZE 512

+

...}}

−

#[...]}}

+

−

where poolsize is {{ic|<nowiki>4096 = INPUT * OUTPUT</nowiki>}}

+

The kernel's pool size is given by {{ic|INPUT_POOL_WORDS * OUTPUT_POOL_WORDS}} which makes, as already stated, 4096 bits.

Contents

Kernel built-in RNG

The Linux kernel's built-in RNGs /dev/{,u}random are highly recommended for producing reliable random data providing the same security level that is used for the creation of cryptographic keys. The random number generator gathers environmental noise from device drivers and other sources into an entropy pool.

Note that the man random command will misdirect to the library function manpage random(3)
while for information about the /dev/random device files you should run man 4 random to read random(4).

/dev/random

/dev/random uses an entropy pool of 4096 bits (512 Bytes) to generate random data and stops when the pool is exhausted until it gets (slowly) refilled. /dev/random is designed for generating cryptographic keys (e.g. SSL/SSH), but it is impractical to use for wiping current HDD capacities: what makes disk wiping take so long is waiting for the system to gather enough true entropy. In an entropy-starved situation (e.g. a remote server) this might never end, while doing search operations on large directories or moving the mouse in X can slowly refill the entropy pool.

You can always compare /proc/sys/kernel/random/entropy_avail against /proc/sys/kernel/random/poolsize to keep an eye on your entropy pool.

While Linux kernel 2.4 did have writable /proc entries for controlling the entropy pool size in newer kernels only read_wakeup_threshold and write_wakeup_threshold are writable. The pool size is now hardcoded in kernel line 275 of /drivers/char/random.c:

The kernel's pool size is given by INPUT_POOL_WORDS * OUTPUT_POOL_WORDS which makes, as already stated, 4096 bits.

/dev/urandom

/dev/urandom

reuses existing entropy pool data while the pool is replenished and although not suited for the most crucial cryptographic purposes, for example the generation of longterm keys, its quality should be sufficient for a paranoid disk wipe, preparing for block device encryption, wiping LUKS keyslots, wiping single files and many other purposes.

/dev/random uses the kernel entropy pool and will halt overwriting until more input entropy once this pool has been exhausted. This can make it impractical for overwriting large hard disks.

/dev/urandom in contrast will reuse entropy when low on it so you won't get stuck. Nevertheless it might still take a long time to bottle-feed the neverending surge of large drives with data.

The output may contain less entropy than the corresponding read from /dev/random. However it is still intended as a pseudorandom number generator suitable for most cryptographic purposes,

Warning: /dev/urandom is not recommended for the generation of long-term cryptographic keys.