Deepees’s Blog

Just another WordPress.com weblog

Creating Large files in Unix

Posted by deepees on February 18, 2009

If only a certain number of characters is needed, use dd:

dd if=/dev/random of=myfile.dat bs=1024 count=10

With this command (and bs=1024), the count is in kilobytes. Thus, the example will create a 10K file. Using the Korn shell, one can use this command to get megabytes:

dd if=/dev/random of=myfile.dat bs=$(( 1024 * 1024 )) count=100

This command will create a 100M file (since bs=1048576 and count=100).

One can also use the mkfile command under Linux to do this

Using the mkfile command on Linux

# mkfile 1m 1MEGABYTE

One Response to “Creating Large files in Unix”

  1. deepees said

    Found that switching to the non-blocking /dev/urandom

    dd if=/dev/urandom of=myfile.dat bs=$(( 1024 * 1024 )) count=100

    This makes a less random file but takes much less time

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

 
%d bloggers like this: