Using dd to Make a Clone of a Drive

Giorgos Keramidas keramida at
Fri Feb 10 02:30:51 PST 2006

On 2006-02-09 18:48, Kevin Kinsey <kdk at> wrote:
>Giorgos Keramidas wrote:
>> Bah!  That's too slow for my taste.  I would usually go for a newfs,
>> dump, and restore option.  For instance, to create a copy of /usr on a
>> second disk:
>>    newfs -U /dev/ad1s1a
>>    mount /dev/ad1s1a /mnt
>>    dump -0 -a -L /usr | ( cd /mnt ; restore ruvf - )
>> Copying with dd(1) is not as fast :)
> Sorry to butt in --- but I'm needing to start cloning too.  Looks
> like a winner to me ... wouldn't this have the added advantage
> of making "same size and geometry" (cf. Erik Trulsson, 4 hours ago,
> this thread) less relevant?

Yes, this is pretty much the important point :)

> As long as the "new" slice had enough space, geometry shouldn't
> matter to dump|restore ....  <?>

Right :)  It also allows restoring in a different partition layout.

I used this recently to 'recover' my laptop's installation, using a
spare partition.  Before running 'installkernel' and 'installworld',
a backup of my root, /var and /usr partitions was saved with:

    # cd /home/backup
    # dump -o -aL -f root.ad0s1a /
    # dump -o -aL -f var.ad0s1d  /var
    # dump -o -aL -f usr.ad0s1e  /usr

A 'copy' of the original /, /var and /usr was restored in ad0s2a, which
was a single UFS partition, large enough to hold a restored copy of my
old /, /var and /usr partitions:

    # newfs -U /dev/ad0s2a
    # mount /dev/ad0s2a /mnt
    # ( cd /mnt;      restore -ruf /home/backup/root.ad0s1a )
    # ( cd /mnt/var ; restore -ruf /home/backup/var.ad0s1d  )
    # ( cd /mnt/usr ; restore -ruf /home/backup/var.ad0s1e  )

Then, when things went totally nuts after the installation of a new
system on ad0s1* partitions, I could still boot from ad0s2a and restore
my old backup copies from /home :)

More information about the freebsd-questions mailing list