[CentOS] How to copy a system?

Thu May 5 13:03:13 UTC 2011
Les Mikesell <lesmikesell at gmail.com>

On 5/5/11 6:13 AM, Timothy Murphy wrote:
> Is there a standard way of copying a working system
> from one machine to another with different partitions?
>
> I have two CentOS-5.6 machines, say A and B,
> and I thought I would copy / on sdb10 on machine A
> to an unused partition sda7 on machine B with rsync.
> I made the appropriate changes to /etc/fstab and grub.conf ,
> as well as /etc/sysconfig/network-scripts ,
> but found that there were innumerable errors
> when I booted machine B into the new system,
> mostly to do with creating dev's.

That's normal.  Anaconda does a bit of magic during the install in detecting the 
hardware and setting things up for it.  Within limits, running kudzu will adjust 
some of them and sometimes it will kick off automatically when hardware 
differences are detected.

> Also the ethernet connection, which had been eth1 on A,
> was now eth0 on B, and this did not work.

That will always happen even what you think is identical hardware, but if you 
are at the machine you can fix it manually.  If kudzu runs it will set up the 
interfaces for dhcp and discard your old settings.

> This was only a kind of experiment.
> There is a problem with the partition table on machine A,
> and I thought it would be useful to have a backup machine
> with exactly the same setup.
>
> Is this a hopeless enterprise, or can it be done easily?

Neither.  It isn't easy and I think that is a real deficiency in Linux 
distributions because most people probably think they can have their backups 
working quickly if their machine dies.  But, it also isn't hopeless - you just 
have to know as much about hardware and drivers as anaconda does.  Or you can 
cheat and do an install on the new machine first and keep at least the initrd or 
all of /boot and perhaps modprobe.conf and a few other things.  In general it is 
better to plan for a new install and have backups that don't overwrite the 
system part but there is not a clean separation between system files and you 
own, so plan to spend a lot of time sorting out things from your backups of /etc 
and /var and merging them.

-- 
   Les Mikesell
    lesmikesell at gmail.com