LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
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 08-03-2012, 04:27 PM   #1
R00ts
Member
 
Registered: Mar 2004
Location: Austin TX, USA
Distribution: Ubuntu 11.10, Fedora 16
Posts: 547

Rep: Reputation: 30
Can dd be used to create an output file larger than the input file?


I have a 10MB input file and a 30GB output file that I need to produce. What I am looking for is a way to instruct the dd program to continue reading the 10MB file as many times as needed to produce the 30GB output file. Example:

Code:
dd ifile=/root/input_file ofile=/root/output_file bs=1M count=30720
Currently if I try to do this, dd will stop once the end of the input file is reached, so the output file is the same size as (and identical to) the input file. I can't do any tricks like using piping of multiple commands, as I need to measure the time it takes for this single dd call to complete.

I've looked through man pages and have searched around and I haven't been able to find anything that would suggest that this is possible, so this is my last resort. Does anyone have any idea as to how this could be done? (Ideally, the solution is to use a command-line argument available in dd to get me this functionality, but I haven't seen such an ability). Thanks!
 
Old 08-03-2012, 06:11 PM   #2
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: Rocky Linux
Posts: 4,783

Rep: Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214
You would have to run dd multiple times, using "conv=notrunc oflag=append" on the 2nd and subsequent invocations.
 
1 members found this post helpful.
Old 08-03-2012, 07:39 PM   #3
jefro
Moderator
 
Registered: Mar 2008
Posts: 22,008

Rep: Reputation: 3629Reputation: 3629Reputation: 3629Reputation: 3629Reputation: 3629Reputation: 3629Reputation: 3629Reputation: 3629Reputation: 3629Reputation: 3629Reputation: 3629
I might have built the 29+G file and added the input to it.
 
Old 08-03-2012, 11:02 PM   #4
Kenhelm
Member
 
Registered: Mar 2008
Location: N. W. England
Distribution: Mandriva
Posts: 360

Rep: Reputation: 170Reputation: 170
A single dd command can create a 30M file from a 10M file by appending the file to itself twice, i.e. if the output file is the input file.
Code:
file="file.tmp"
head -c10m < /dev/zero  > "$file" 
stat -c%s "$file"
10485760                 # 10Mbyte

dd if="$file" of="$file" seek=10 bs=1M count=20

20+0 records in
20+0 records out

stat -c%s "$file"
31457280                 # 30Mbyte
 
2 members found this post helpful.
Old 08-06-2012, 10:28 AM   #5
R00ts
Member
 
Registered: Mar 2004
Location: Austin TX, USA
Distribution: Ubuntu 11.10, Fedora 16
Posts: 547

Original Poster
Rep: Reputation: 30
Thanks Kenhelm, I think that might work for me. Ideally I'd like the input and output files to be different, because the input file is to be stored on a RAM disk and the output file is located on a hard disk that we are trying to test the performance of. But given that the input is only 10MB and the output is 30GB, I don't think it will matter too much.
 
  


Reply

Tags
dd



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
NFS Large File Copies Fail - Error writing to file: Input/output error deck- Linux - Server 10 08-01-2022 02:30 AM
data from input file to be taken and send to output file grishu Linux - Newbie 18 08-03-2010 08:02 AM
Using command output as file input FlowState Linux - Software 1 05-14-2008 07:30 PM
Can't rm file with Input/Output error drlaz Linux - General 0 02-23-2005 06:06 PM
how to use the output of a file for input of a command sneak Linux - General 2 05-12-2004 09:21 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 10:11 PM.

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
Open Source Consulting | Domain Registration