How to duplicate a HD using dd

jdow jdow at earthlink.net
Sat Oct 11 23:12:33 UTC 2003


From: "Thiago Vinhas de Moraes" <tvinhas at techbyte.com.br>
> Em Sáb, 2003-10-11 às 19:16, jdow escreveu:
> > From: "Thiago Vinhas de Moraes" <tvinhas at techbyte.com.br>
> >
> > > Sory for the OT, but does anyone the best way to duplicate a HD in
> > > Fedora, just like Norton Ghost does in Winblows?
> > >
> > > I tried to use dd if=/dev/hda of=/dev/hdb, but the proccess has never
> > > stoped, after a few hours.
> > > Both are 40Gb hard drives, but from different manufacters. One is a
> > > Maxtor, and the other one is a Samsung.
> >
> > If the drives are basically the same size with the destination drive
> > being the larger drive if you elect to waste some drive, then the
> > dd approach is the fastest. However it is best to add a suitable
> > "bs=8225280" or if you don't wish to be so profligate with memory
> > "bs=131072" should be nearly as fast.
> >
> > "dd if=/dev/hda of=/dev/hdb bs=131072", for example
>
> What's the difference between "bs=8225280" and "bs=131072" ?
>
> I tried without the "bs" and when booted with the copied drive, got
> infinite fsck problems that I don't have with the original hd. Do you
> know why?

I've no idea. One might say RTFMP here. Man pages really are worthwhile
reading. "bs" is block size. The larger value happens to be one full
cylinder. The smaller value is 128k bytes, 2048 blocks. It's a "nice"
value for older (and perhaps current) IDE drives that have 15 bit
transfer counters. The default copy is performed block by block. So
it gets VERY slow with the overhead of reading one block then writing
one block repeatedly.

You MAY have an addressing problem for the drive. But the kernel
should have the drives figured out. If the destination drive is
smaller than the source drive that will kill your last partition.
If the drive is a single partition drive that could be the problem.

Actually, I use a slightly different script.
I copy exactly one block starting at block zero. Then I copy the rest
of the logical cylinder skipping the first block on the two disks. Then
I copy by logical cylinders for the rest of the disk, skipping the first
cylinders on the two disks.

This script came about due to a crazed set of logic in some older
SCSI drives that would become unusable until reformatted if you ever
wrote more than one block starting at exactly block zero. I've never
figured out the reason for this. But it has bitten me so hard in the
past that I've eschewed ever doing it again. I've not seen the effect
on IDE/ATA drives. But I tend to the "too many times bitten time to
be shy" philosophy. (Yeah, that one's bitten me twice. Sometimes I
fail to learn from my own mistrakes and have to kick myself around
the block a few times.)

If you are not trying to clone a root filesystem disk you might be
better off simply creating matching partitions on the new drive and
"cp -a" all the data from partition to partition. That has a minor
advantage of eliminating some of the file fragmentation that grows
on active data drives.

{^_^}





More information about the fedora-test-list mailing list