Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

A few days ago I was delighted to find out that it's not all that difficult to write an iso image to a USB without the help of a third-party program explicitly designed to do so. But the command (or program) that facilitates this - dd - puzzles me.

According to Wikipedia it's designed to copy and convert raw data, but honestly I find this definition very equivocal and vague. I understand that it lets you turn one piece of data into another, but what happens if the specified output file is too small to be turned into the specified input file?

dd if=giant_file of=tiny_file

Also, when I create a bootable USB with an image file, the USB attains a filesystem type of isofs, but if I write an archive or executable to the drive, it retains its regular filesystem type.

Any clarification of what the dd command really does or how it works on a lower level would be much appreciated. Thanks!

share|improve this question

2 Answers 2

up vote 7 down vote accepted

dd does a byte-by-byte copy from the source to the destination, with an optional conversion specified by the conv argument. It performs reads and writes as specified by the *bs and *flag options, with the range defined by the count, skip, and seek options.

what happens if the specified output file is too small to be turned into the specified input file?

If of is too small to contain if then the data is truncated to fit. Note that if of is a regular file then it is overwritten.

share|improve this answer
1  
of is overwritten even if it's not a file - this is a very nice way to (accidentally?) destroy a partition/drive! That's why it's very important to double and maybe triple check the destination if it's a drive/partition, to make sure you have the right one. –  Bob Aug 1 '12 at 6:32
1  
Technically it writes into the object rather than overwriting it. –  Ignacio Vazquez-Abrams Aug 1 '12 at 6:38
    
Thanks for the answer. What if you don't include any arguments, but do something like dd if=executable of=archive.tar, assuming they are both the same size. Will the archive be transformed flawlessly into the executable? –  Alex Reidy Aug 1 '12 at 16:58
1  
It will do a byte-for-byte copy from executable to archive.tar 512 bytes at a time. It will not turn the binary into an archive. –  Ignacio Vazquez-Abrams Aug 1 '12 at 17:40

I won't even try to summarize what is in these links, but you may find them useful (or too-much-info) ... They are both from Unix & Linux (stackexchange)

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.