Operating System - HP-UX
1751694 Members
5131 Online
108781 Solutions
New Discussion юеВ

Re: Using "touch" command to create large files?? Is it possible??

 
SOLVED
Go to solution
Victor BERRIDGE
Honored Contributor

Re: Using "touch" command to create large files?? Is it possible??

Hi Angie,
I did put e.g. Yes it creates (or reseves) a 100Mb space Up to you to adapt to your needs
note that
prealloc ./test 100000000 creates test of about 100MB
>> /tmp/testperf2 creates a file of 100MB in /tmp
I use this to see how my disks work when I suspect an issue...
You would need then >50000000000

All the best
Victor
Pete Randall
Outstanding Contributor

Re: Using "touch" command to create large files?? Is it possible??

Here's another demo of doing this with prealloc:

$ bdf
File System......Mbytes....Used.. Avail %Used Mounted on
/dev/vg00/lvol3.... 200.... 169......31.. 85% /
/dev/vg00/lvol1.... 288......56.... 203.. 22% /stand
/dev/vg00/lvol8....3000.... 431....2550.. 14% /var
/dev/vg00/lvol7....3000....1067....1918.. 36% /usr
/dev/vg00/lvol6.... 200......40.... 159.. 20% /tmp
/dev/vg00/lvol5....2000....1625.... 372.. 81% /opt
/dev/vg00/lvol4....1600.... 582....1012.. 36% /home
$ prealloc filler 1000000000
$ bdf
File System......Mbytes....Used.. Avail %Used Mounted on
/dev/vg00/lvol3.... 200.... 169......31.. 85% /
/dev/vg00/lvol1.... 288......56.... 203.. 22% /stand
/dev/vg00/lvol8....3000.... 431....2550.. 14% /var
/dev/vg00/lvol7....3000....1067....1918.. 36% /usr
/dev/vg00/lvol6.... 200......40.... 159.. 20% /tmp
/dev/vg00/lvol5....2000....1625.... 372.. 81% /opt
/dev/vg00/lvol4....1600....1535......65.. 96% /home


Pete

Pete
Angie_1
Regular Advisor

Re: Using "touch" command to create large files?? Is it possible??

WOW look at all the feedback I got an so quick! Thank you all of you.

I ended up using dd if=/dev/zero bs=1k seek=52428799 count=1 of=mybigfile and then I copied the file it created to another file, and it worked good. Didn't take too long either. I wanted to use this command too because I may use this on a Linux system here too.

Thanks for all the great feedback again and will post some points to all you brainiacs!

Have a nice day!
Angie
Angie_1
Regular Advisor

Re: Using "touch" command to create large files?? Is it possible??

Ok I really appreciate the efforts earlier but have ran into a snag. Though the files are getting created, 50 GIGs a piece , when I do a "df" command it says that still only 1% of the filesystem is in use. But of course when I do an "ll" it shows all the 50 gig files. Now someone mentioned if I copy this "dd" created file to another file it would fix this but this doesn't seem to be the case.

I did the following:

dd if=/dev/zero bs=2k seek=26214399 count=1 of=file1

See below:

-rw-r--r-- 1 root root 53687091200 2005-05-18 11:52 file1
-rw-r--r-- 1 root root 53687091200 2005-05-18 11:58 file2
-rw-r--r-- 1 root root 53687091200 2005-05-18 12:00 file3
-rw-r--r-- 1 root root 53687091200 2005-05-18 12:02 file4

But again with a "df" command still shows only 1% is in use when it should be like 50% in use with 20 of these 50-gig files.

Thanks for responding.
Angie
A. Clay Stephenson
Acclaimed Contributor

Re: Using "touch" command to create large files?? Is it possible??

What does a du -k report in this directory? The cp command should have worked because on sparse files the read() system call silently pads the unallocated blocks with ASCII NUL's completely invisible to the application.

I just tried a 20MB sparse file and copied it and ls -l and du -k reported just as expected as did df -k.
If it ain't broke, I can fix that.
Angie_1
Regular Advisor

Re: Using "touch" command to create large files?? Is it possible??

The following is shown and still with df it shows just 1% use.

host:/test/temp # du -k
1024005

Angie
Angie_1
Regular Advisor

Re: Using "touch" command to create large files?? Is it possible??

Ok I missed an earlier post... I am trying this...as it seems to be working... a bit modified as was mentioned. I don't understand though why changing the block size to 256k?

dd if=/dev/zero bs=256k count=204800 of=mybigfile

Angie
A. Clay Stephenson
Acclaimed Contributor

Re: Using "touch" command to create large files?? Is it possible??

Because it would take forever and a day to write 50GB in 1k blocks. You should set the blocksize to at least 64k for that operation and not much is to be gained above 256k; 256k is a reasonable chunk. Reads above 1MB are silently broken into (at most) 1MB chunks.

I still don't know why cp did not completely copy the sparse file. I would try "cat < file1 > file2".
If it ain't broke, I can fix that.
Angie_1
Regular Advisor

Re: Using "touch" command to create large files?? Is it possible??

Ok thanks for explaining... I will use the 256k then as that makes more sense.

Thank you.. this is going to work out great!

Angie
Amit Agarwal_1
Trusted Contributor

Re: Using "touch" command to create large files?? Is it possible??

somtimes I use tail command to create huge files.

$ echo "some dummy stuff" >> filename
$ tail -1000 -f filename >> filename

After few minutes of runnning it would grow to large size. You can press Ctrl-C to interrupt and check the size, if it is not yet 5GB, you can continue with the tail command.