At first glance it doesn't care much.<br><br>[sean@bob ddtest]$ echo "hello" > test<br>[sean@bob ddtest]$ ls -l test<br>-rw-rw-r-- 1 sean sean 6 Feb 21 21:43 test<br>[sean@bob ddtest]$ dd if=test of=test.out
bs=1k<br>0+1 records in<br>0+1 records out<br>6 bytes (6 B) copied, 0.000157303 seconds, 38.1 kB/s<br>[sean@bob ddtest]$ ls -l test.out<br>-rw-rw-r-- 1 sean sean 6 Feb 21 21:43 test.out<br><br>Flip through the source code to
dd.c:<br><br>/* The number of bytes in which atomic reads are done. */<br>static size_t input_blocksize = 0;<br><br>/* The number of bytes in which atomic writes are done. */<br>static size_t output_blocksize = 0;<br><br>
You'd have to browser a bit deeper to get the One True Answer, there looks like there are several different types of copying that can happen, each has different behaviours.<br><br>notrunc is a bit easier, it's only referenced in two places, both in the same function. It seems to be a direct setting/clearing of O_TRUNC to open(2):
<br><br> O_TRUNC<br> If the file already exists and is a regular file and the open<br> mode allows writing (i.e., is O_RDWR or O_WRONLY) it will be<br> truncated to length 0. If the file is a FIFO or terminal device
<br> file, the O_TRUNC flag is ignored. Otherwise the effect of<br> O_TRUNC is unspecified.<br><br>Sean<br><br><br><div><span class="gmail_quote">On 2/21/07, <b class="gmail_sendername">Dan Martin
</b> <<a href="mailto:ummar143@cc.umanitoba.ca" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">ummar143@cc.umanitoba.ca</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Can someone tell me how the dd command handles block sizes? The man<br>page and any Linux books I have don't explain it very well.<br><br>If I specify<br>dd if=\dev\mydevice ... bs=1M<br>What happens if mydevice has a fraction of a block left over?
<br><br>What is "notrunc" for the output file? Truncation from what to what?<br><br>--<br> -Dan<br><br>Dr. Dan Martin, MD, CCFP, BSc, BCSc (Hon)<br><br>GP Hospital Practitioner<br>Computer Science grad student
<br><a href="mailto:ummar143@cc.umanitoba.ca" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">ummar143@cc.umanitoba.ca</a><br>(204) 831-1746<br>answering machine always on<br><br>_______________________________________________
<br>Roundtable mailing list<br><a href="mailto:Roundtable@muug.mb.ca" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">
Roundtable@muug.mb.ca</a><br><a href="http://www.muug.mb.ca/mailman/listinfo/roundtable" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">http://www.muug.mb.ca/mailman/listinfo/roundtable</a><br><br>
</blockquote></div><br><br clear="all"><br>-- <br>Sean Walberg <<a href="mailto:sean@ertw.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">
sean@ertw.com</a>> <a href="http://ertw.com/" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">http://ertw.com/</a>