LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 09-05-2003, 05:41 PM   #1
wizade
LQ Newbie
 
Registered: Feb 2003
Posts: 14

Rep: Reputation: 0
Question Weird question... Fastest way to create large arbitrary files?


Often I find myself running tests (such as transfer speed) where I need large files as testers. Doesnt matter whats in them... just use them for the data transfer or whatever.

Normally I do a:

head -c SIZE /dev/urandom > filename

where SIZE is the size of the file I need in bytes.

The problem is that for files over a few megs this method is slow because you have to wait on the machine to fill it with random information.

So my question... Is there a way to create files of arbitrary sizes instantly. Like... some way to manipulate the file descriptor so that a file is allocated a large amount of space. ???

Someone told me there is a way.. but I have no idea.

Thanks
 
Old 09-05-2003, 05:50 PM   #2
Saraev
Member
 
Registered: Apr 2002
Location: Los Gatos, CA
Distribution: boring redhat 9
Posts: 163

Rep: Reputation: 30
[root@jebus root]# time head -c 100000000 /dev/zero >filename

real 0m2.174s
user 0m0.090s
sys 0m0.830s
[root@jebus root]#

P3 1ghz machine w/256 MB ram.
 
Old 09-05-2003, 06:10 PM   #3
wizade
LQ Newbie
 
Registered: Feb 2003
Posts: 14

Original Poster
Rep: Reputation: 0
awesome!

thats fast enough...

what is /dev/zero?

 
Old 09-05-2003, 06:12 PM   #4
Saraev
Member
 
Registered: Apr 2002
Location: Los Gatos, CA
Distribution: boring redhat 9
Posts: 163

Rep: Reputation: 30
It's one of those "black hole" special files. If you use it to make a ten meg file, then try to cat that file, you'll see that there's not a damn thing in the file.

Think of it as a filesize BS machine.
 
Old 09-05-2003, 07:01 PM   #5
wizade
LQ Newbie
 
Registered: Feb 2003
Posts: 14

Original Poster
Rep: Reputation: 0
takes about 30 secons for a gig file on my dual processor machine.

I wonder if there is a way to just manipulate a file so this process can be instant?
 
Old 09-06-2003, 01:32 AM   #6
J.W.
LQ Veteran
 
Registered: Mar 2003
Location: Boise, ID
Distribution: Mint
Posts: 6,642

Rep: Reputation: 84
If you want the process to be instant, why don't you just create the huge file(s) once, then not delete it? Sure, you'll waste a chunk a space, but since it sounds like this activity is something you do frequently, why not save yourself the trouble of having to create these bogus files each time. -- J.W.
 
Old 09-06-2003, 02:27 AM   #7
wizade
LQ Newbie
 
Registered: Feb 2003
Posts: 14

Original Poster
Rep: Reputation: 0
because thats not an interesting solution

And a sysadmin told me it was possible but not obvious. (and he couldnt remember either)
 
Old 09-06-2003, 02:38 AM   #8
J.W.
LQ Veteran
 
Registered: Mar 2003
Location: Boise, ID
Distribution: Mint
Posts: 6,642

Rep: Reputation: 84
A fair enough assessment. At the same time though, which is better: A non-interesting solution that actually works exactly the way you want it to, or spending a lot of time trying to track down rumors about a potentially faster solution, which few people, if any, seem to be able to recall? -- J.W.
 
Old 09-06-2003, 03:05 AM   #9
wizade
LQ Newbie
 
Registered: Feb 2003
Posts: 14

Original Poster
Rep: Reputation: 0
they have actually done it for some project.. ill make him look it up and ill post the solution

for now doing a head on /dev/zero is pretty darn good
 
Old 09-06-2003, 03:37 AM   #10
MasterC
LQ Guru
 
Registered: Mar 2002
Location: Salt Lake City, UT - USA
Distribution: Gentoo ; LFS ; Kubuntu
Posts: 12,612

Rep: Reputation: 68
FWIW, I believe /dev/zero is actually the writing of zero's to the HD.

Cool
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Large Dell LCD with weird fonts Neruocomp Linux - Hardware 0 06-22-2005 01:03 PM
short smb question (create files) CarLost Linux - Networking 5 06-14-2004 09:58 AM
Linux, Create Dirs=no, Create files=yes. Possible? tisource Linux - General 4 01-12-2004 10:05 PM
Large Number of files? mikeshn Linux - Security 2 01-10-2004 06:11 AM
How to backup large files( > 2G or 4G)? myunicom Linux - General 4 09-24-2003 08:17 PM


All times are GMT -5. The time now is 05:15 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration