[SUMMARY] How to clone the system disk

From: Jean-Loup Risler <jean-loup.risler_at_genetique.uvsq.fr>
Date: Mon, 14 Feb 2000 10:50:50 +0100

Dear Gurus,

My question was: what is the best way to clone the system disk?
                 (I forgot to make it clear that I use UFS, not AdvFS)

Purpose: replace the system disk by the clone in case of crash

As usual, this list proved to be great: I received more than 15 answers,
too many to list everybody. Thanks to all of you!

Most answers (e.g. V. Becker, S. Reavell, T. Blinn, J. Hamlin and L.
Bro) gave the same solution:

- if the spare disk (onto which you want to clone the system disk) and
the system
  disk are IDENTICAL, then the simplest is to use dd. As Lars Bro said:
  
  make a dd copy, that is the far easiest. If you make the copy from the
  "raw" device, you get everything including the label. (the target disk
  should be of the same type as the original).

  Since the two disks were identical I did the following:

1) put the spare disk somewhere in the StorageWorks unit (happened to be
rz1)
2) went to single user mode (init s).
3) made sure that the spare disk had no label: disklabel -z rz1
4) made the copy with the following command:
   dd if=/dev/rrz0c of=/dev/rrz1c bs=1024k

   (I got several different suggestions for the block size, from 1024 to
    65536, including 2048 and 8192)

5) checked the clone:
   fsck /dev/rrz1c

Worked like a charm!

Here are copies of some typical answers:

#############
from Volker Becker:

the easiest and fastest way to clone the disk is probably the 'dd'
command, e.g.

 dd if=/dev/rrz<1>c of=/dev/rrz<2>c bs=1024k
        (source disk) (destination disk)

for usage of the 'dd' command, both disks should be identical
and if the destination disk is 'raw', the disklabel has to be
zeroed out first (disklabel -z rz<2>), but it is not necessary to
partition the disk manually.
##############
from Simon Reavell:


If your Discs are ~*IDENTICAL*~ then you can use dd on the c partitions
which copies the entire disc. For example dd if=/dev/rrz1c of=/dev/rrz2c
bs=1024k which copies the entire disc you know as rz1 to rz2 if they are
IDENTICAL discs. This is best done from single user mode, though I have
done
this from Muti on an non-loaded system then ran fsck on the copied
partitions which worked. If the discs differ in any way I found the best
method to be to create the partitions, and filesystems, on the blank
disk
then use dump | restore to copy the partitions one by one. For example
dump
-0f - /dev/rz1a | (cd /temp_part_mount ; restore -a) you could also use
blocking factor here to good effect on speed. Again the same comment
about
single user mode as before. The second method will probably be quicker
as it
only copies data whereas the first copies the entire disc.
###############
from Dr. Tom Blinn:

If the spare disk is at least as large as the master copy, and it's the
only use you want to make, one of the most straight-forward ways to make
the copy is with the "dd" utility, copying the raw "c" partition from
the
master disk to the spare disk. As long as the spare disk has no label
when you start (use disklabel -z to wipe the label), you'll get an exact
copy. The BEST way to do this is with the system shut down to single
user
mode, or better yet, from an alternate boot disk, because you'll have an
EXACT copy of the state of your file systems. Using "fsck" should clean
up any inconsistencies, but if you've got the master (source) disk
mounted
at the time of the "dd", the on-disk status is what gets copied. Also,
bear in mind that you will need to adjust the /etc/fstab in the copy to
point to the correct SCSI ID (unless you will move the disk to the SCSI
ID that's expected if you ever need to use it as a boot disk). This is
one of the things that changes in V5.x.

Alternatively, use utilities like dump/restore or vdump/vrestore to copy
your file systems over. This takes longer, and you have to
appropriately
label the target disk and move the partitions one at a time, with each
of
the target locations mounted appropriately, but it does work. I've done
it MANY times to "clone" system disk.
#################
from Jef Hamlin:

Shutdown the system to single user mode (I've found that it is even
better
to shut it all the way down and then boot to single user mode), blank
the
disk you wish to copy TO by doing a "disklabel -z rzYY", then do a "dd
if=/dev/rzXX of=/dev/rzYY", where XX is your original root disk and YY
is
the copy. You'll end up with an exact replica your root disk (and all
other
file systems on that disk).
##################
from Lars Bro:

I supppose that in case your system disk crashes, you would simply put
the
other one in and then boot from that one instead.

Then make a dd copy, that is the far easiest. If you make the copy from
the
"raw" device, you get everything including the label. (the target disk
should be of the same type as the original).

For example, The root disk is rz0, the copy is rz12

# disklabel -z rz12
# dd if=/dev/rrz0c of=/dev/rrz12c bs=8192k

For a 4 Gb disk it takes 20 min on a 1200.
###################

Thanks again and cheers,

Jean-Loup

---------------------------------------------------------------------
| Jean-Loup Risler | |
| Universite de Versailles | Tel: 33 (0)1 39 25 45 54 |
| Lab. Genome et Informatique | Fax: 33 (0)1 39 25 45 69 |
| Batiment Buffon | |
| 45 Avenue des Etats-Unis | email: risler_at_genetique.uvsq.fr |
| 78035 Versailles Cedex France | |
---------------------------------------------------------------------
Les cerveaux sont malencontreusement pourvus d'estomac (J. Perrin)
Received on Mon Feb 14 2000 - 09:52:01 NZDT

This archive was generated by hypermail 2.4.0 : Wed Nov 08 2023 - 11:53:40 NZDT