blog.apolloner.eu

Moving existing Xen machines into XenServer

My current Xen machines use one logical volume per disk, for XenServer I need those in VDI files/volumes. This is how I moved them onto XenServer:

  • Prepare the new machine via XenCenter or use xe vm-install.

  • Determine the uuid of the new VDI via xe vdi-list and write it down.

  • Create a new VBD for the control domain:

    xe vbd-create device=0 vm-uuid=uuid_of_xen_control_domain vdi-uuid=uuid_of_vdi bootable=false mode=RW type=Disk
    
  • Attach it to the Dom0 via xe vbd-plug.

  • Use fdisk to create a partition table and filesystem (make sure it's at least as big as the old -- probably a bit bigger to be safe).

  • Power down the old virtual machine move the config file out of /etc/xen/auto to prevent unwanted restarts.

  • Make sure that the new XenServer vm has it's networking stuff (mac addr!) configured correctly.

  • Use dd and ssh to copy the logical volume into the new VDI:

    dd if=/dev/mapper/vg-vm_disk | ssh root@XenServer "dd of=/dev/xvda1"
    
  • run e2fsck -f /dev/xvda1 followed by resize2fs /dev/xvda1 to make sure the filesystem fills up the space properly.

  • mount /dev/xvda1 on the Dom0 and make sure to replace the old device strings (probably sdX with xvdX). At least you will need to look into /etc/fstab and /boot/grub/menu.lst.

  • Unmount it again and unplug (xe vbd-unplug) the block device from the Dom0 (just to be safe).

  • Change the boot loader for the new virtual machine to pygrub otherwise it will try to run installation procedures:

    xe vm-param-set uuid=uuid_of_virtual_machine PV-bootloader=pygrub
    
  • Fire up the virtual machine and see if everything works.

I did this for two machines now and it worked like a charm.

0 comments: