Mailinglist Archive: opensuse (1355 mails)

< Previous Next >
Re: [opensuse] dd to copy a partition?
  • From: Greg Freemyer <greg.freemyer@xxxxxxxxx>
  • Date: Wed, 13 Jun 2018 19:15:24 -0400
  • Message-id: <>
On Wed, Apr 11, 2018 at 1:30 PM, Felix Miata <mrmazda@xxxxxxxxxxxxx> wrote:
Lew Wolfgang composed on 2018-04-11 07:51 (UTC-0700):

One of my acolytes reported that she used dd to copy one
disk partition to another partition on the same disk, as in:

dd if=/dev/sda1 of=/dev/sda2

She said it failed, but was a little fuzzy about exactly what
happened (I wasn't there), just that the destination partition
appeared to be "empty" after the operation. I don't know
how she made that determination.

I've been doing UNIX stuff for a long time but I never would
have thought to use dd in this fashion. Maybe instinct? But
assuming that the two partitions are exactly the same size,
what could possibly go wrong?

dd if=/dev/sda1 of=/dev/sda2 stands a significant chance of failure on an MBR
disk. Before it became standard practice to leave a gap of 1.0MiB or 2.0MiB in
front of the first partition, sda1 would be a different size in sectors from
ostensibly identically sized sda2, sda3 or sda4. The latter three would
typically be larger than sda1 by 62 sectors. The latter three would also be
larger than a "same" size logical. IIUC, with a standard gap from recent
partitioning tools the difference between the first and up to three
primaries would be gone, but not the difference between primaries and
So, sda2 or sda3 to sda5 or sda13 should fail in any event.

Were the destination partition a nominal size larger than the source, then dd
could do OK, and there would be some unused sectors at the end of the

Another failure mode would be making an exact clone and not immediately
accounting for having multiple filesystems with identical UUIDs and possibly
volume labels, whether MBR disk or GPT. One or the other would need to be
differentiated (e.g. with tune2fs -U and maybe -L) before either were put into
use via mounting.

Another failure mode would be attempting to clone an in use (mounted)
also same whether MBR or GPT, with files open and who knows what else that
result in filesystem inconsistency when attempting to put it into use.

In addition to Felix's comments, dd aborts by default on a read or write error.

I don't use dd often for that job, but when I do it's "dd if=/dev/sda1
of=devsda2 bs=1M conv=noerror,sync"

noerror says not to abort on an error and sync says to null fill any
failed reads.


To unsubscribe, e-mail: opensuse+unsubscribe@xxxxxxxxxxxx
To contact the owner, e-mail: opensuse+owner@xxxxxxxxxxxx

< Previous Next >