Debian P2V
Debian Physical to Virtual migration.
This is a very basic brain dump of actions taken to migrate a Debian physical to a Xen virtual machine. It needs to be reviewed and refined...
Prepare
Create the Debian Virtual Machine which will receive the Physical Machine data
Code: shell |
xen-create-image --hostname=... |
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
Synchronization
To minimize downtime for the actual migration, one can synchronize the data beforehand:
Code: shell |
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 |
As far as I can see, the only files we really need to keep are the kernel modules, but that needs to be confirmed.
Test
Once synchronized the above image can easily be tested
Mount the disk image and chroot it
Code: shell |
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)!
Code: shell |
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
Code: shell |
umount /mnt xm create -c /etc/xen/<virtual machine>.cfg |
Migrate
- 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
Migration done!
Post-install
There are a couple of things that can be done afterwards:
- Configure for pygrub (See Debian and pygrub)
- Uninstall unneeded packages (mdadm, ...)
- ...