Pages

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 !!!

4 comments:

  1. 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/

    ReplyDelete
  2. freebsd dd also supports the common size units

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

    makes a 1GB file

    ReplyDelete
  3. /dev/zero is much faster data source than /dev/random

    ReplyDelete