[CentOS] Clone physical into virtual

Les Mikesell lesmikesell at gmail.com
Wed Aug 8 17:14:44 UTC 2007


Rick Barnes wrote:
> Scott Moseman wrote:
>> Is there a formal, or preferred, method for importing a physical
>> CentOS machine into a VMware instance?  I know they make
>> software to move Windows machines, but I couldn't find one to
>> handle our CentOS servers.  I have done something via scp/sftp
>> in the past, which *seemed* to work, but if there's a better way
>> I'm more than interested in hearing the process.
> 
> What has worked for me is to use a liveCD to boot the image and then use
>   ssh and tar to clone the machine to the virtual drives. You can find
> people suggesting netcat to do it but the ssh /tar method works because
> just about every liveCD has ssh and tar. Just mount the drive on the
> virt server say /mnt/newroot/, and if you separate images from
> 
> from the image run:
> # ssh remote.box.com tar c / | tar x -C /mnt/newroot
> 
> Adjust the tar attributes as needed.

This will have the same issues as moving to a different physical 
machine, but if you ever have to deal with backup/resores it is a good 
idea to understand them.  First, you need to make sure the filesystems 
you create are compatible with the target OS version.  For example, if 
you mke2fs with the default options from a Centos4/5 boot/rescue CD, 
then copy over a centos 3 machine, it won't work - and the same for LVM 
versions if you use them.  Then after the copy, you may have to adjust 
the /etc/fstab  and /boot/grub/grub.conf copies to reflect new partition 
names or add filesystem labels to match the old names, and install grub.
If the disk controller or VMware emulation is not the same as the old 
system (and not IDE) you have to build a new initrd image, too.

-- 
   Les Mikesell
    lesmikesell at gmail.com




More information about the CentOS mailing list