Debian P2V

Un article de Bulles.
Aller à : navigation, rechercher

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


Note: This is to be refined and tested. To have an exact copy of the Physical Machine, we should use the --delete option if we synchronize multiple times; but that would also delete the files from our pre-seeded Xen environment.

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

  1. Shutdown all services but sshd on the source server.
    I actually boot in maintenance mode and start sshd manually.
  2. Synchronize the data (see above).
  3. Change the IP addresses on the physical server, as we want to keep the current IP addresses for our migrated server.
  4. 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
  5. Unmount the image
  6. Start the virtual machine

Migration done!

Post-install

There are a couple of things that can be done afterwards:

  1. Configure for pygrub (See Debian and pygrub)
  2. Uninstall unneeded packages (mdadm, ...)
  3. ...