2011-02-14

FreeBSD - How to create big huge files

Platform :
FreeBSD

Purpose :
Create big files for testing purpose.

Command :
dd

Installation :
The "dd" command comes with the base installation.

Useful switches :
if == input file. By default, dd reads from standard input (stdin)
of == output file name
bs == block size of input & output
count == how many blocks to create for the output file, essentially the size of the file in megabytes

Example :
This would create a file with 100mb in size :
dd if=/dev/random of=myfile.dat bs=$(( 1024 * 1024 )) count=100

And this would create a file with 1000mb in size :
dd if=/dev/random of=myfile.dat bs=$(( 1024 * 1024 )) count=1000


Arrivederci !!!

3 comments:

surlyjake said...

Nice tip.
You can also use 'mkfile' for things like this. i think it might be quicker for large files, since it uses 0's instead of /dev/random. It's available through ports.
http://www.freshports.org/sysutils/mkfile/

PsyberMonkey said...

surlyjake, thanks for the tip! :)

Allan Jude said...

freebsd dd also supports the common size units

dd if=inside of=outfile bs=1m count=1k

makes a 1GB file