Subject: bug#19065: dd design bug

From: Pádraig Brady <[email-masked]>
Date: Sun, 16 Nov 2014 11:55:41 +0000

On 16/11/14 01:11, bt wrote:
> The following undocumented behavior of dd is (IMO) a design flaw.
> 
> If dd is used to copy one partition to another, as in
> 
> #dd if=/dev/sda3 of=/dev/sdb3 ...
> 
> and if in fact sdb3 does not exist, then dd will overwrite the first part of
> an existing partition *sda1*. 
> 
> It doesn't make sense that if the "of=" device doesn't exist, then another
> pre-existing device, not mentioned in the command line, is overwritten.
> Several websites have incorrect information about the behavior of dd in this
> situation. 
> At the very least, this should be documented--maybe I'm missing something, but didn't see it in the man pages or the texinfo manual.

What version of dd are you seeing this with?
What operating system version are you seeing this with?

I'm struggling to see how dd could ever do this itself.
Perhaps you have a dynamic devfs on /dev or something
and when you create /dev/sdb3 it creates a device node
for /dev/sda or something?

That's a major gotcha and I would suggest passing the
conv=nocreat option to dd to avoid that behavior
(yes it would have been better called 'nocreate'
 but not worth changing now after 10 years).

cheers,
Pádraig.