Feb 21, 2013

How to move a VM between hosts? (Not migrate)

Many posts talk about migration.
But, how do we move a VM from one host to another?
This sounds like an easy task but it is not easy to find an how-to on Internet.
So, let's start an easy how-to.



We use Xen 4.0 in this example.
Assume the VM name is Tutorial and it has a virtual disk image file called Tutorial.img

1. Copy/Move virtual disk files.
If both machines are connected on network and running SSH server. You may use scp to copy Tutorial.img from source to destination machine.

        scp Tutorial.img username@xxx.xxx.xxx.xxx:~/

2. Export configuration file.

        xm list -l Tutorial > Tutorial.sxp

3. Move Tutorial.sxp to source machine

        scp Tutorial.sxp username@xxx.xxx.xxx.xxx:~/

4. Import the VM on target machine

        xm new -F Tutorial.sxp

Note: You need to make sure the path of image files is correct. Also, another common problem is the path of boot loader.

5. Enjoy your VM

        xm start Tutorial


This method can also be used to clone VMs.
But, remember to check all uuid and mac addresses on the same machine.

Ending picture:
Public market center. Seattle, WA



No comments:

Post a Comment