Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.


How to create dummy 2G file

How to create dummy 2G file

I would like to create a dummy file on a file system to verify that the file system can handle this size of a file.  I thought I could do this with the dd command using if=/dev/null of=/targetdirectory.
But I don't know how to tell it to put 2G of lovalues in the file.   I know there is a way - but maybe it is not using the dd command.  Anyone with an idea ?  I have already tried adding the dd options of count= and iblks=

RE: How to create dummy 2G file


you could write a Perl script to create a large file, something like this would do it.

#!/usr/bin/perl -w

my $buf = ' ' x (1024 * 1024);
my $i;

open(F,'>mybigfile') || die "can't open file\n$!\n";

  print F $buf;


Cargill's Corporate Web Site
Making mistakes, so you don't have to. <grin>

RE: How to create dummy 2G file

Don't need PERL to do that, simply use

dd if=/dev/zero of=/your/new/filename bs=1m count=4

First... when you read from /dev/null nothing goes out, but /dev/zero generates a continuous stream of zeroes. Give it a input and output block size of 1MB with bs=1m (you can use k to specify KiloBytes, and b to specify blocks).

I hope it works...

RE: How to create dummy 2G file

Thanks - the dd=/dev/zero .... worked fine.  

RE: How to create dummy 2G file

Hi guys
    there is a command in aix that creates a file with null characters its is lmktemp. the syntax is lmktemp filename size-of-file in bytes eg to create a 100 byte file called test. You type lmktemp test 100.

Let us know of the outcome.



RE: How to create dummy 2G file

The lmktemp worked fine - actually faster than the dd command.  Thanks.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!


Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close