Skip to content

Write for instance random data with multiple threads. Useful to fill a hard disk with data from /dev/urandom, where dd or cat would only use one core.

License

Notifications You must be signed in to change notification settings

nischu/rand_write

Repository files navigation

Build it with:
./configure
make

use it with:

./rand_write > /dev/disk
to write random data to /dev/disk with four threads.

If you want to specify the number of threads to be started, use the -n
parameter:
./rand_write -n 16 > /dev/disk

If your random device has a different name, use the -f parameter:
./rand_write -f /dev/myrandomdevice > /dev/disk




BEWARE!!!!
==========

The use of this little tool is to overcome a pretty simple limitation in various
UNIX kernels: If you open /dev/urandom, random number calculation is done in the
calling process' context. This means, there will only be ONE thread calculating
random numbers and if you have a multiple core machine, they will stay about
idle.

So we create n threads that open the given device, so in case of /dev/urandom,
there will be n threads calculating random numbers. THE DATA IS WRITTEN TO THE
PIPE IN ARBITRARY ORDER! This means, you should NOT EVER try to use this program
for anything but RANDOM DEVICES! If you think it would be clever to read e. g.
a disk image with this tool to be faster, you will most probably suffer from
data corruption, since the input file will be output with mixed-up 4k chunks.

There is no use in using anything BUT /dev/urandom for this utility since
reading /dev/zero will not be any faster since there is no data to be
calculated by the kernel. Any other "useful" input would be mixed up.

About

Write for instance random data with multiple threads. Useful to fill a hard disk with data from /dev/urandom, where dd or cat would only use one core.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published