cancel
Showing results for 
Search instead for 
Did you mean: 

Re: create a huge file

 
SOLVED
Go to solution
rleon
Regular Advisor

create a huge file

I read in the forums a while back a way to create a huge file.

I am trying to test monitoring and need to fill up a filesystem.

Thanks
7 REPLIES 7
Ivan Krastev
Honored Contributor

Re: create a huge file

Use dd:

To create a 5 GB file:

# dd if=/dev/zero of=bigfile bs=1m count=5000

regards,
ivan
Hasan  Atasoy
Honored Contributor

Re: create a huge file

Hi pbsg ;

dd if=/dev/zero of=/yourfs/tmp.tmp bs=1024k count=1000

will create 1GB file. you can flay with count and get desired file.

Hasan
Todd McDaniel_1
Honored Contributor
Solution

Re: create a huge file

I believe the command you are looking for is called:

# prealloc name size

It creates a file of the specified size.



Enjoy!!

Unix, the other white meat.
James R. Ferguson
Acclaimed Contributor

Re: create a huge file

Hi:

One way:

# perl -e 'open(FH,">",$ARGV[0]);seek(FH,1024*1024,1);print FH "\n"' filename

This will create a file of 1 MiB characters with a name of your choice ("filename"). Change the value to whatever you want.

Regards!

...JRF...
Armin Kunaschik
Esteemed Contributor

Re: create a huge file

James,

this will (probably) create a sparse file and will not fill up the filesystem.
Use prealloc to allocate a file with all zero's in it!

My 2 cents,
Armin
And now for something completely different...
James R. Ferguson
Acclaimed Contributor

Re: create a huge file

Hi (again):

> Armin: James, this will (probably) create a sparse file and will not fill up the filesystem.

Ah, yes, you are correct. I glossed over the part about wanting to fill up the filesystem.

If you choose to create the sparese file, as I suggested, you can inflate it by doing a simply copying it with 'cp' as you would any file.

Armin, that's for pointing this out.

Regards!

...JRF...


Geoff Wild
Honored Contributor

Re: create a huge file

prealloc is the way to do it on HP-UX:

prealloc test.100mb 102400000


creates a 100MB file.

Rgds...Geoff
Proverbs 3:5,6 Trust in the Lord with all your heart and lean not on your own understanding; in all your ways acknowledge him, and he will make all your paths straight.