Skip to main content

Migrate to XCP-ng

If you are using another virtualization platform (VMware, KVM, etc.), this part of the documentation will help you to migrate to XCP-ng.

caution

OVA import will miss the information if the VM is running BIOS or UEFI mode. Double check your settings on your original system, and then enable (or not) UEFI on XCP-ng side for the destination VM. You can do so in VM advanced tab in Xen Orchestra.

From XenServer

We got a dedicated section on how to migrate from XenServer to XCP-ng.

From Citrix Hypervisor

We got a dedicated section on how to migrate from Citrix Hypervisor to XCP-ng.

From Xen on Linux

If you are running Xen on your usual distro (Debian, Ubuntu…), you are using xl to manage your VMs, and also plain text configuration files. You can migrate to an existing XCP-ng host thanks to this Python script.

  1. Get that script in your current dom0.
  2. Shutdown your VM
  3. Run the script, VM by VM with for example: ./xva.py -c /etc/xen/vm1.cfg -n vm1 -s xcp_host_1 --username=root --password="mypassword" --no-ssl. You can use a hostname or the IP address of your XCP-ng host (name xcp_host_1 here)
  4. Your disks are streamed while the configuration file is "translated" to a VM object in your XCP-ng host.
  5. As soon it's done, you should be able to boot your VM on destination
  6. Repeat for all your VMs

If you have an error telling you that you don't have an default SR, please choose a default SR on your XCP-ng pool (in XO, Home/Storage, hover on the storage you want to put by default, there's an icon for it).

caution

This script is a bit old and not tested since while. If you have issues, feel free to report that!

From Virtualbox

Export your VM in OVA format, and use Xen Orchestra to import it. If you have an issue on VM boot, check the VMware section.

From VMware

Using OVA export from VMware and then OVA import into Xen Orchestra is the preferred way.

tip

Collect info about network cards used in windows VM (ipconfig /all) use same mac address(es) when creating interfaces in xcp-ng this step will help You skip windows activation if system was activated already.

Importing a VMware Linux VM, you may encounter an error similar to this on boot:

dracut-initqueue[227]: Warning: /dev/mapper/ol-root does not exist

The fix for this is installing some xen drivers before exporting the VM from VMware:

dracut --add-drivers "xen-blkfront xen-netfront" --force

See here for more details. Once the imported VM is properly booted, remove any VMware related tooling and be sure to install Xen guest tools.

From Hyper-V

There's two options, both requiring to export your Hyper-V VM disk in VHD format.

caution

When exporting in VHD, always use a dynamic disk VHD format and not static, which doesn't work in XCP-ng.

In any case, you must remove all the Hyper-V tools before exporting the disks.

Import the VHD in Xen Orchestra

In the left menu, go for "Import" then "Disk". Select the destination SR, and then add your VHD file into it. Depending on the VHD file size, it might take some time. The upload progress can be tracked in another XO tab, in the "Task" menu.

When the disk is imported, you can:

  1. Create a VM with the appropriate template, without any disk in it
  2. Attach the previously imported disk (VM/Disk/Attach an existing disk)
  3. Boot the VM
  4. Install the tools

Alternative: direct VHD copy

caution

This method is a bit more dangerous: if you don't respect the VHD name format, the SR will be blocked and giving warnings. Naming is crucial to avoid problems.

It's possible to directly send the VHDs to an existing XCP-ng SR. However, you MUST respect some pre-requisites:

  • to use a dynamic disk VHD format
  • the VHD MUST be named correctly (see below)

VHD naming

The ONLY working format is <UUID>.vhd, eg e4e573d8-6272-43ae-b969-255717e518aa.vhd. You can generate an UUID by simply using the command uuidgen.

Steps

  1. Rename the dynamic VHD disk to the format <UUID>.vhd
  2. Copy it to the destination SR (any file type is supported: local, NFS…)
  3. Scan the SR
tip

As soon you did scan the SR, the new disk is visible in the SR/disk view. Don't forget to add a name and a description to be able to identify it in the future. Indeed, any disk imported this way won't have any metadata, so it's up to you to fill it.

  1. Create a VM with the appropriate template, without any disk in it
  2. Attach the previously imported disk (VM/Disk/Attach an existing disk)
  3. Boot the VM
  4. Install the tools
tip

If You lost ability to extend migrated volume (opening journal failed: -2) You need to move disk to another storage, VM should be ON during moving process. This issue can occur when vhd files was directly copied to storage folder.

From KVM (Libvirt)

Related forum thread: https://xcp-ng.org/forum/topic/1465/migrating-from-kvm-to-xcp-ng

Due the fact I have only server here, I have setup a "buffer" machine on my desktop to backup and convert the VM image file.

  • Install the dracut packages : yum install dracut-config-generic dracut-network

    dracut --add-drivers xen-blkfront -f /boot/initramfs-$(uname -r).img $(uname -r)

    If your VMs are in BIOS mode :

    dracut --regenerate-all -f && grub2-mkconfig -o /boot/grub2/grub.cfg

    If your VMs are in UEFI mode (OVMF Tianocore) :

    dracut --regenerate-all -f && grub2-mkconfig -o /boot/efi/EFI/<your distribution>/grub.cfg

  • Shutdown the VM

  • Use rsync to copy VM files to the "buffer" machine using --sparse flag.

  • Convert the QCOW2 to VHD using QEMU-IMG :

    qemu-img convert -O vpc myvm.qcow2 myvm.vhd

  • Use rsync to copy the converted files (VHD) to your XCP-ng host.

  • After the rsync operation, the VHD are not valid for the XAPI, so repair them :

    vhd-util repair -n myvm.vhd

    vhd-util check -n myvm.vhd should return myvm.vhd is valid

  • For each VM, create a VDI on Xen Orchestra with the virtual size of your VHD + 1GB (i.e the virtual size of myvm is 21GB, so I create a VDI with a size of 22GB).

  • Get the UUID of the VDI (on Xen Orchestra or CLI) and use the CLI on the XCP-ng host to import the VHD content into the VDI :

    xe vdi-import filename=myvm.vhd format=vhd --progress uuid=<VDI UUID>

  • Once the import is done, create a virtual machine using XO or XCP-ng Center, delete the VM disk that has been created and attach your newly created VDI to the VM. Don't forget to set the VM boot mode to UEFI if your VMs was in UEFI mode.

  • Boot the VM and find a way to enter in the virtual UEFI of the VM. Here, I type the Escape and F9,F10,F11,F12 keys like crazy. Select Boot Manager, you should see this window :

  • Select UEFI QEMU HARDDISK, the screen should be black for seconds and you should see the GRUB. Let the machine worked for minutes and you should see the prompt finally 👍

  • Install Guest Tools and reboot. The reboot shouldn't take long, you don't have to redo step 13, the OS seems to have repair the boot sequence by itself.

Done !