[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: dd effect on cloning of iso file to usb stick

From: Eric Blake
Subject: Re: dd effect on cloning of iso file to usb stick
Date: Thu, 02 Oct 2014 19:38:21 -0600
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.1.1

On 10/02/2014 07:00 PM, jb wrote:

> It looks like fdisk, cfdisk, etc are confused about identifying those 
> partitions and their start/end sectors. Is there a partition table at all ?
> If so, where is it located, sectorwise ?

No, they are all accurately reading the partition table.  The partition
table lives in sector 0 of both the .iso and of your just-written
/dev/sdb, and it is that partition table that then tells the kernel
where the boundaries of /dev/sdb1 and /dev/sdb2 are, if that partition
table was encoded to list multiple partitions.

> Ouch !
> What dd does is not a neutral cloning (bit-by-bit) but some kind of
> transformation of a source (if=) to different binary object targets.

You sound confused.  How do you think disks work?  /dev/sdb is how you
access EVERY SINGLE SECTOR of the underlying device; and it is the
bit-perfect copy that you wrote into sector zero that says how to
interpret the rest of the sectors.

> Is that by design ? I was not aware of such dd's capability ...

dd just did a byte-wise copy.  ANY program that does a byte-wise copy on
sector boundaries would have the same result; it's nothing special about
dd.  How do you think fdisk writes partitions?  By writing to sector
zero of the raw disk.

> Also, is such behavior by dd not risky w/r to making backups by cloning ?

Actually, when cloning a hard drive, you WANT to copy the entire image,
including sector zero, to cover ALL partitions (and any file systems
embedded within those partitions), and NOT limit the copy to a single
partition.  There's a reason that it is usually only root that can
access /dev/sdb, so that ordinary users don't accidentally clobber their
hard drive; but the point remains that the ability to byte-wise clone
all partitions of a disk in one command is a nice feature when it is needed.

> After all, the purpose of a backup is to have it restored, eventually, in
> a symmetrical, one-to-one manner.

Your usb stick IS a symmetrical one-to-one copy of the iso - the iso
itself was encoded with multiple partitions.  It's no different than
what virtual machine disk images can do - a single file within the file
system of the host machine which looks like a disk with multiple
partitions to the guest machine.  It's all in how people agree to
interpret the data in sector 0.

> There is nothing in dd(1) about such a capability.

What would you add?  Patches are welcome, if you think there's a
shortcoming in the coreutils documentation.

Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library

Attachment: signature.asc
Description: OpenPGP digital signature

reply via email to

[Prev in Thread] Current Thread [Next in Thread]