Skip site navigation (1)Skip section navigation (2)
Date:      01 Oct 2002 13:42:18 -0700
From:      swear@attbi.com (Gary W. Swearingen)
To:        Mike Hogsett <hogsett@csl.sri.com>
Cc:        "Pranav A. Desai" <pdesai1@cs.uh.edu>, freebsd-questions@FreeBSD.ORG
Subject:   Re: how to use 'dd' to create image of a hard drive?
Message-ID:  <zpsmzpx55h.mzp@localhost.localdomain>
In-Reply-To: <200209302345.g8UNjQZN049714@axp.csl.sri.com>
References:  <200209302345.g8UNjQZN049714@axp.csl.sri.com>

next in thread | previous in thread | raw e-mail | index | archive | help
Mike Hogsett <hogsett@csl.sri.com> writes:

> Please anyone correct me if I am wrong, but I believe that when you are
> using dd with a raw disk blocksize only effects performance and does not
> have any effect on the duplicated data.

That's what I've read, but I once had problems with "dd" handling the
end of what I wanted to transfer.  It might have been on Linux and it
probably wasn't writing to a disk device, but ever since, I've been
careful to try to use a "bs" which is an integer multiple or divisor of
the device block size, if I know it (the disk driver apparently hides it
here, whether the disk is "raw" or not) or an integer divisor of the
device size.

The default bs=512 never gives problems, but makes for slow transfers.

I always make my partitions integer multiples of cylinder size (a
debatably policy - see below) and I used the cylinder size as the "bs"
last time I did this sort of thing.  IIRC, I also did it using a bs
equal to the size of the thing I was copying, determined from one or
more of these:
    fdisk ad1
    disklabel ad1
    newfs -N ad1

Note that there is another set of conflicting terminology to consider.
The "block size" (or "bsize") mentioned by "disklabel" and "newfs" are
rather large FreeBSD things which "newfs" groups into larger things
called "cylinders" and groups those into "groups".  Those groups and
cylinders are allowed to be cut short by the end of a partition (loosely
speaking), and the "newfs" implies that it is giving you every last
sector of the partition (ie, allowing the last block to be cut short --
don't let it's "unallocated" comment fool you), but I'm guessing that it
really wastes up to one block (a small multiple of sector size) which
I suppose can contain random data without harm (but I don't know).

It seems clear that these blocks and cylinders can both can straddle the
fictional (CHS-type) tracks and cylinders, so instead of sizing a
partition as a multiple of track or cylinder size, it probably makes
more sense to size it as a multiple of the expected newfs block size.
(That is a function of the partition size, so unless you know the
algorithm, trial and error might be needed to get it correct.)  If you
can get them both to come out even, you won't get the "*" marks from
"disklabel" warning you about partitions not lining up with cylinders.


Back to the original question:

My current "/" device on ad0s2 was dd'd from ad0s4 and "disklabel ad0s2"
shows:

    # /dev/ad0s2c:
    type: ESDI
    disk: ad0s4

Apparently, the erroneous disklabel (showing s4, not s2) is harmless.


P.S. to Mike: Please don't quote so much stuff which you don't refer to.

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?zpsmzpx55h.mzp>