This should be the fastest way to do it:
SEEK=$SIZE-1
dd if=/dev/zero of=outfile bs=1 seek=$SEEK count=1
Otherwise just write a quick and dirty C or perl program that does a seek to the exact position and writes a single byte. This is a LOT faster than actually dumping data onto the blocks.
If you want to avoid sparse files then on Linux (and possibly other systems) you can use fallocate -l <length>
from util-linux
.
If that's unavailable, and you have a POSIX compliant system then you can write a quick and dirty program using posix_fallocate() library call. posix_fallocate guarantees allocation of the range specified so you will not get a disk-full on subsequent use of the range if it returns successfully
9
Related SO question: http://stackoverflow.com/questions/257844/quickly-create-a-large-file-on-a-linux-system
– Der Hochstapler – 2013-06-18T13:49:22.733