Xen Clone

From ConShell
Jump to navigation Jump to search


This page describes most of the steps necessary to migrate an existing system into a Xen domainU. The process is still a bit rough around the edges. This example is based on a CentOS-3 system, but should be more-or-less applicable to others.

In this environment LVM is used for the virtual disks, and this fact determines the need to prepare the virtual disk prior to cloning. In a file-backed virtual disk environment, shortcuts could be made but at the cost of performance.

First create the storage (e.g. /dev/mapper/vg01/vol08 or /path/to/some/file) then run mkfs.ext3 on it and mount it as /mnt/disk

Prepwork (on srchost)

  • Unmount any NFS or other network mounts e.g. smbfs
  • package cleanup (optional)
  • kernels - remove older unused kernels (e.g. rpm -qa | grep kernel ...)
  • folder cleanup, look in /usr/src/, /usr/local/src/, /var/tmp/
  • run yum clean or aptitude autoclean
  • dry-run the rsync command below (-n) and redirect the output into /tmp/report
    • review the report for any gotchas.
    • look for any throw-away folders which can be added to the exclude file (to save disk space and time)

Create a file named XenCloneExlude containing these entries:

 proc/*
 tmp/*
 lost+found/
 etc/mtab


Now perform the rsync command as shown. This is just a test (dry) run.

rsync -av -e ssh
 -n \ #dry run
 -S \ # handle sparse files
 -H \ # Preserve hard links
 -W \ # copy files whole
 -D \ # also get device files
 --exclude-from="XenCloneExclude" \
 root@srchost:/ /mnt/tmp

Or, more succintly...

 rsync -av -e ssh  -n -S -H -W -D --exclude-from="XenCloneExclude" root@srchost:/ /mnt/tmp

Post-copy

  • fix up /etc/sysconfig/network-scripts/ifcfg-eth0 to use a different IP or to use PROTO=DHCP.
  • Remake Devices? (oops - MAKEDEV is in /dev on redhat fix by scp'ing MAKEDEV over)
 scp root@srchost:/dev/MAKEDEV /mnt/disk/dev/
 cd /dev; ./MAKEDEV null random urandom console zero
  • Fix /etc/fstab - because original is no longer valid!!!

First run as guest

Now you can exit the chroot and try to boot the vm.

This might be a good time to pull the plug on the old system 8)

Run this command to start the guest with a console attached

 xm create newname -c

(Red Hat et al.) kudzu should run, remove all old devices

 mv /lib/tls /lib/tls.disabled 

Consider reviewing the network configuration.