XCP-ng
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Register
    • Login

    How do you clone a VM to another host?

    Scheduled Pinned Locked Moved Xen Orchestra
    11 Posts 6 Posters 4.5k Views 4 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • R Offline
      rk9268vc
      last edited by

      I have 2 physical servers (2 hosts)
      I want to migrate the VM to the second server as a copy and keep the original one.
      I do not have enough space on the disk to copy it, then migrate it.

      Is there any way to migrate-clone a VM?

      thanks 🙂

      A 1 Reply Last reply Reply Quote 0
      • A Offline
        Andrew Top contributor @rk9268vc
        last edited by Andrew

        @rk9268vc You can Copy it to the new host and then start it there. It does not migrate the VM but creates a copy ready to boot while the old one is still running (the copy will be out of date if the VM is still running).

        You can Warm migrate (under the Advanced tab) which gives you the option to Delete (or not) the old VM and Start (or not) the new VM. This option will take a while to complete as it copies the VM and then updates the new VM with the changes during the copy.

        You can also Export the VM and then Import it on the new host.

        If you can shut down the original VM during the copy/migrate process then it will happen a lot faster.

        R 1 Reply Last reply Reply Quote 0
        • R Offline
          rk9268vc @Andrew
          last edited by

          @Andrew when i select "copy" it does not give me the option to select the other host, only different disks of the same host.
          The other host does show up as a separate pool so i wonder if that is the issue?

          The VM is around 480 GB and i am moving from a 500GB raid to a 512GB raid so i dont have a lot of wiggle room,

          1 Reply Last reply Reply Quote 0
          • splastunovS Offline
            splastunov
            last edited by

            Live migration is not possible in this case, because of lack of free space.

            You have to shutdown VM, then click this button and chose another host

            aa215cc3-784e-4211-95a2-e8a24e006644-image.png

            R 1 Reply Last reply Reply Quote 1
            • R Offline
              rk9268vc @splastunov
              last edited by

              @splastunov Hi. The VM doesnt have to be live migrated, shutdown is fine.
              The problem is migrate moves the VM. I want to simply copy the VM to the new machine and keep the instance on the current one.
              If I migrate, it will be gone from the current machine.
              I do not have the storage space to clone the VM first, then migrate on either host.

              what i want to do is clone, but to another host, not to the same host - if that makes sense

              1 Reply Last reply Reply Quote 0
              • olivierlambertO Offline
                olivierlambert Vates 🪐 Co-Founder CEO
                last edited by

                There's a copy button in Xen Orchestra (cf the previous screenshot, in the same bar, the last icon on the right). Copy is a XO feature that will stream the VM to the destination, and in the end make a copy. I suggest you spend some time exploring all XO capabilities, there's many chances it's already covered by existing features 🙂

                R 1 Reply Last reply Reply Quote 0
                • R Offline
                  rk9268vc @olivierlambert
                  last edited by

                  @olivierlambert Hi, thanks for the comment.
                  As mentioned, it does not give me the option to copy to the other host. When I select copy, it only shows the disks of the current host as targets.
                  The only way that I see to see the other host as a target is with migrate.
                  Is there a setting or something to be able to see others hosts when copying?
                  thanks

                  1 Reply Last reply Reply Quote 0
                  • olivierlambertO Offline
                    olivierlambert Vates 🪐 Co-Founder CEO
                    last edited by

                    XO should list all existing SR (as long as the pool is connected in XO obviously), regardless the pool.

                    1 Reply Last reply Reply Quote 0
                    • P Offline
                      pctechsolution
                      last edited by

                      I'm having same issue, is there any update to this? I can migrate between hosts but when I hit copy it doesn't allow me to copy between hosts and only shows the host on which it's on.

                      I have an XENServer host (primary) and XCP-ng (new server). I Can migrate from xenserver to xcp-ng but can't copy for some reason?

                      1 Reply Last reply Reply Quote 0
                      • splastunovS Offline
                        splastunov
                        last edited by splastunov

                        There is no implementation in XAPI to "copy" VM to remote host (maybe XO has it own implementaion I'm not sure).
                        Copy works only localy.
                        You can only migrate it to remote host.

                        Disclaimer.
                        Everything you do on your own risk.

                        But you can do it manually by export/copy VDI from one host to another.
                        If you do not need "live" copy while VM is running, just stop VM, get all VBDs xe vbd-list vm-name-lable={VM-name}.
                        You will see all VBDs and VDIs of VM.
                        Go to certain SR cd /var/run/sr-mount/{SR-UUID} and copy VDI to new host's SR (you can use scp).
                        On destination host:

                        1. Get new VDI UUID vhd-util read -p -n {VDI-UUID}.vhd
                        2. Rename file using this UUID
                          91acf2f8-fbdd-4a6e-b85a-3520c00ddec9-image.png
                        3. Rescan SR on destination host.
                        4. Create VM, attach VDI.

                        If VDI stored on "shared" SR (iSCSI, NFS, ceph rbd and etc...), firts you have to export VDI by command xe vdi-export uuid={VDI-UUID} filename={VM-Name_xvda}.vhd format=vhd --progress
                        After success export, copy to destination host, read, rename and etc....

                        If you need "live" migration you can do it with minimal down time via snapshot.

                        1. Make snapshot with uniq name.
                        2. List VBDs xe vbd-list vm-name-lable={VM-name}.
                        3. Export all VDIs xe vdi-export uuid={VDI-UUID} filename={VM-Name_xvda}.vhd format=vhd --progress (repeat for all VDIs).
                        4. Copy to destination host
                        5. Use vhd-util to get new UUID and rename VDI vhd-util read -p -n {VDI-UUID}.vhd
                        6. Shutdown VM. Do not delete VM before it will not start successfully on "new" host!
                        7. Get snapshot list xe snapshot-list
                        8. Get disks in snapshot xe snapshot-disk-list uuid={snapshot_UUID}
                        9. Export diff xe vdi-export uuid={main_VDI_UUID_from_step_3} filename=2920_delta_xvda.vhd format=vhd base={snapshot_VDI_UUID_from_step_8)} --progress
                        10. Copy diff to destination host
                        11. Import diff xe vdi-import uuid=VDI_UUID_from_step_5 filename=2920_delta_xvda.vhd format=vhd --progress
                        1 Reply Last reply Reply Quote 0
                        • D Offline
                          DustinB
                          last edited by

                          The simple answer here is to use the Continuous Replication backup type. It'll copy the VM to another host on whatever schedule you set.

                          It couldn't be simpler.

                          1 Reply Last reply Reply Quote 0
                          • First post
                            Last post