Reputation: 855
I need to be able to create a large number of files, randomly-sized 1k-64k averaging 32k, very quickly. One method I've found uses the unix command dd to copy bytes from /dev/urandom into a new file. However, I'm trying to save the time by just creating the file link to unallocated space, without writing random bytes to disk.
Is this possible in a Unix-like environment and, if so, how would I go about it?
If not, could this be done with a small C program?
Upvotes: 1
Views: 571
Reputation: 62379
From the commandline, mkfile
or dd
or any number of other (not-necessarily POSIX-standard) utilities. I would note that copying from /dev/zero
instead of /dev/urandom
can be significantly quicker, especially on older systems with slower CPUs.
If you want to do something in C or C++ code, there's truncate()
and ftruncate()
. Probably most Perl/Python/whatever bindings expose the system/libc call in some way as well.
Upvotes: 2