If you want to set up a xen image on a different server than the one you have it running on, once you have copied all the files (image.img, image-swap.img, image-config.img,…) there are some things that you have to have into account.
- Change the config file: the config file has to be according with the new path of the files and you might probably want to change also the way that the virtual image behaves regarding the start, shutdown, or the new network configuration, that might be different if we move network.
But not only changing the configuration file will make our image start correctly, because it can start but with some failures regarding modules dependencies, this can be because when we change the image form a computer to another, if the kernel of the host is not the same as the kernel of the previous host xen server, the modules dependencies wouldn’t be the same and in the “creation” of the image, xen will complain because of this. But there is an easy way to solve this issue it and make xen happy in this step.
- Mount the xen image in a directory by using mount -o loop image.img mount-directory by doing this you can access to the file system of the image as if any other device would it be.
- In the host go to /lib/modules, crate a directory called as your kernel name (mkdir `uname -a`), go inside this new folder and run depmod -a this will create several dependencies modes for your host computer.
- Copy this entire folder into the image it has to be also in the folder /lib/modules and it will tell xen which kernel you have and where to find dependencies for the modules.
- Umount the guest image directory umount mount-directory
Now is when we can start our xen image as we use to do so: xm create -c image-comfig.cfg (-c if we want to see the start console, that helps to see whether if we have a problem or not during the start).
I hope this small tip helps you with the deployment of xen images in different servers.