Generating files of any size
A file of random data is useful for testing. You can use such files to test application efficiency, to confirm that an application is truly input-neutral, to confirm there's no size limitations in your application, to create loopback filesystems (loopback files are files that can contain a filesystem itself and these files can be mounted similarly to a physical device using the mount
command), and more. Linux provides general utilities to construct such files.
How to do it...
The easiest way to create a large file of a given size is with the dd
command. The dd
command clones the given input and writes an exact copy to the output. Input can be stdin
, a device file, a regular file, and so on. Output can be stdout
, a device file, a regular file, and so on. An example of the dd
command is as follows:
$ dd if=/dev/zero of=junk.data bs=1M count=1 1+0 records in 1+0 records out 1048576 bytes (1.0 MB) copied, 0.00767266 s, 137 MB/s
This command creates a file called junk...