[K12OSN] Server Clone

Les Mikesell les at futuresource.com
Fri May 28 17:39:45 UTC 2004

On Fri, 2004-05-28 at 08:32, Jim Kronebusch wrote:

> Well I have been trying a few different things, restore was the first
> from a full system dump to NFS mount via webmin without any luck.  The
> other was rsync but my syntax is very questionable (rsync -e ssh -avz
> --delete-after user at server:/ /), that managed to render my new server
> unbootable afterwards :-)

Two things go wrong using any file-by-file method to clone a
machine.  Both easy enough to fix.

First, the RH/fedora install adds labels to your filesystems and
uses the labels instead of the device names for the partitions
in /etc/fstab.  This sounds good in theory because you can add
controllers or move the drives on the connectors and it will still
find the labels, but it sucks in practice because the labels aren't
unique across machines and moving an already labeled disk to another
machine using the same label (say to recover data or just re-use the
disk) will make it unbootable.  So, I recommend fixing this before
cloning. Do a 'df' or 'mount' on the master machine, note the device
names for the partitions (/dev/sda1, etc.) and their mount points
and edit /etc/fstab to use those instead of the "LABEL=/" notation
as first item on the entries.  Be careful about this, but note that
the technique mentioned next can recover a mistake or you can clone
with the labels and recover on the copy. 

The second problem is that the new copy needs a boot loader installed.
If you boot with lilo, any time you change the kernel file location
(new version, copied files, etc.) you must rerun /sbin/lilo to
update the map it uses to tell bios what sectors to load at boot time.
Grub loads in several stages that end up being able to read the
filesystem to find the kernel, but you still have to get it installed
on a cloned system.  The simple way is to boot the just-cloned copy
with  the RH/k12ltsp/fedora install CD and at the boot prompt type
"linux rescue".   This will boot from CD, then attempt to find a
working system and mount it as /mnt/sysimage.  If you didn't change
/etc/fstab before the copy you will probably have to mount the
partition containing /etc by hand and change the copied fstab file
to use the current device partitions where you just copied things.
(Be sure you have a matching swap partiton as well, formatted with
mkswap).  CD out of your mounted partion and unmount it if you
had to do this step, then you can either reboot or mount the
/boot partion in it's logical place yourself.  Once fstab is
correct, booting in rescue mode will mount the partitions under
/etc/sysimage and show you the chroot command to go there for
rescue work.  Type 'chroot /mnt/sysimage' and you will run commands
more or less normally.  Use '/sbin/lilo' if your master system used
lilo, or 'grub-install' if it used grub.  

>   I am really nervous about entering the wrong
> command and killing files on the original server.  Also if I get
> something to work, I am worried about whether or not it will be a true
> clone or if only enough files are alike to seem that way which could
> lead to problems down the road.

If your disk drives are identical, you can clone them with a sector
by sector copy and you'll get boot loader, labels and everything.
Boot the new to-be-copy machine with a Knoppix CD.  From the knoppix
menu item, pick 'root shell'.  Then (assuming a single scsi drive
that is /dev/sda on both) do:
ssh master_server "dd if=/dev/sda" | dd of=/dev/sda
Go have lunch - this will take a long time.

With either approach, the copy will have the same hostname and IP number
as the master.  Unless you are replacing the original machine you should
boot the new one with the network disconnected until you change the
name and address.

  Les Mikesell
   les at futuresource.com

More information about the K12OSN mailing list