Visit Jeremy's Blog.
Go Back > Forums > Linux Forums > Linux - Software
User Name
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.


  Search this Thread
Old 08-03-2012, 05:27 PM   #1
Registered: Mar 2004
Location: Austin TX, USA
Distribution: Ubuntu 11.10, Fedora 16
Posts: 545

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:

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, 07:11 PM   #2
Senior Member
Registered: Aug 2009
Distribution: CentOS
Posts: 2,333

Rep: Reputation: 975Reputation: 975Reputation: 975Reputation: 975Reputation: 975Reputation: 975Reputation: 975Reputation: 975
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, 08:39 PM   #3
LQ Guru
Registered: Mar 2008
Posts: 13,891

Rep: Reputation: 1773Reputation: 1773Reputation: 1773Reputation: 1773Reputation: 1773Reputation: 1773Reputation: 1773Reputation: 1773Reputation: 1773Reputation: 1773Reputation: 1773
I might have built the 29+G file and added the input to it.
Old 08-04-2012, 12:02 AM   #4
Registered: Mar 2008
Location: N. W. England
Distribution: Mandriva
Posts: 333

Rep: Reputation: 141Reputation: 141
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.
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, 11:28 AM   #5
Registered: Mar 2004
Location: Austin TX, USA
Distribution: Ubuntu 11.10, Fedora 16
Posts: 545

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.



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

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

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