I want to create the file to implement a I/O benchmark on linux.
Thanks in advance, Antonio
I want to create the file to implement a I/O benchmark on linux.
Thanks in advance, Antonio
If you are using a filesystem which supports it, you can do this with fallocate
. Here is the command line version
/tmp/tmp.tO6EDnuWXT λ > fallocate -l 10MiB derp
/tmp/tmp.tO6EDnuWXT λ > du derp
10240 derp
There is also a C API for this. http://man7.org/linux/man-pages/man2/fallocate.2.html
If the contents of the file do not matter, you can do something like:
dd if=/dev/random of=./derp bs=1024 count=10000
bs
is the block size, so in the above example I am creating the file in 1024 (1K) chunks, and count
is how often I do this (1K * 10000 = 10M). See https://www.linuxnix.com/what-you-should-know-about-linux-dd-command/ for more examples