Migrate a Xen Instance to VMware
12/11/2012 10:10:00 PM
Posted by johnhomer
This procedure decribes the process of migrating an instance/phyical
server to another instance/phyical server. There are a number of ways on
doing the same e.g. vCenter Converter but contrary to the post title, if you want a generic and
hypervisor agnostic way, this is it!
The whole idea is to copy (thru SSH)
from the source instance to the destination instance (the one you are
currently logged-on in rescue mode). Before doing the actual copy thru SSH, the disk you are copying into, should have been partitioned and formatted as described in the process.
My test environment is the following:
The source DomU is run through PyGrub. So if you're not doing PyGrub, you may have to install a kernel before you reboot.
- Source Hypervisor: Xen 4.x
- Destination Hypervisor: VMware ESXI 5.1
- Source OS: CentOS 6.3 with LVM root partition, ext4
- Destination OS: Same, no LVM, ext4
- On the destination hypervisor, create a VM with the desired CPU/memory setup. Make sure to add a CDROM device with an ISO file source (i used CentOS netinstall iso). Also, make sure that the VM boots from this CDROM
- Boot to rescue mode. Enable networking. Don't mount the root partition (we'll do that in the next step)
- Partition, format and mount the target disk to /mnt/sysimage. During partitioning, don't forget to tag the partition with a bootable flag
fdisk /dev/sda mkfs.ext4 /dev/sda1 mkdir /mnt/sysimage && mount /dev/sda1 /mnt/sysimage
- Copy the files (OS) from source instance to the target disk. This is where all the magic happen
cd /mnt/sysimage ssh root@source_instance 'cd /; tar -zcvf - --exclude=dev --exclude=proc --exclude=media --exclude=mnt --exclude=sys *' | tar -zxvf -
- Chroot to the target root folder and mount dev, proc and sys folders
mkdir dev proc sys mount -o bind /dev dev chroot . mount -t proc none /proc mount -t sysfs none /sys
- In order for the new system to run, modify the following files according to new hardware configuration
/etc/fstab /boot/grub/grub.conf /boot/grub/device.map
- Populate /etc/mtab
grep -v rootfs /proc/mounts > /etc/mtab
- Install grub
grub-install /dev/sda
- Reboot!
- Make sure you set a different IP in /etc/sysconfig/network-scripts/ifcfg-eth0
- Delete /etc/udev/rules.d/70-persistent-net.rules. This will be recreate at boot-time
- Update the system to receive the latest kernel
Post a Comment