Create the Debian Virtual Machine which will receive the Physical Machine data
This is a bit an overkill as we do not really need to install an image in the Virtual Machine, but everything is setup nicely and we can test our configuration.
At this stage we use temporary IP addresses to avoid conflicts.
Synchronise and test
To minimize downtime for the actual migration, one can synchronize the data beforehand:
mount /dev/<path to disk image> /mnt rsync \ --verbose \ --archive \ --numeric-ids \ --hard-links \ --exclude=/tmp \ --exclude=/proc \ --exclude=/dev \ --exclude=/sys \ --compress \ --rsh=ssh \ <physical machine>:/ \ /mnt/ umount /mnt
Once synchronized the above image can easily be tested
Mount the disk image and chroot it
mount /dev/<path to disk image> /mnt chroot /mnt
In the chrooted environment we need to install the Xen version of libc6, modify IPs to avoid conflicts and update /etc/fstab to reflect the Xen disk layout. We also need to ensure that we only start the services we want/need (/etc/rcN.d)!
apt-get install libc6-xen vi /etc/network/interface vi /etc/udev/rules.d/z25_persistent-net.rules vi /etc/fstab # Any other cleanup # ... exit
Unmount the partition and test the Virtual Server
umount /mnt xm create -c /etc/xen/<virtual machine>.cfg
- Shutdown all services but sshd on the source server.
I actually boot in maintenance mode and start sshd manually.
- Synchronize the data (see above).
- Change the IP addresses on the physical server, as we want to keep the current IP addresses for our migrated server.
- Mount the disk image and chroot it as described above. We need to:
- Install libc6-xen
- Cleanup /etc/udev/rules.d/z25_persistent-net.rules
- Cleanup /etc/fstab
- Any other cleanup action
- Unmount the image
- Start the virtual machine
There are a couple of things that can be done afterwards:
- Configure for pygrub (See Debian and pygrub)
- Uninstall unneeded packages (mdadm, ...)