LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Virtualization and Cloud (https://www.linuxquestions.org/questions/linux-virtualization-and-cloud-90/)
-   -   Migration of KVM Guests Flat Files (https://www.linuxquestions.org/questions/linux-virtualization-and-cloud-90/migration-of-kvm-guests-flat-files-937213/)

Sydney 03-30-2012 01:19 AM

Migration of KVM Guests Flat Files
 
Hello,

I have a couple of Guests built in my development environment that I would like to migrate to production. Absolutely no network exists between these two; however, the hardware is the same. I would like to use a USB drive to move the VM's flat files. Does anyone have experience with this? Oh by the way the servers are a 6 hr plane ride apart so I need this to be rock solid. I plan to take dirs to rsync as a contingency plan.

I am pretty new to KVM so please be gentle:)

EricTRA 03-30-2012 03:03 AM

Hello,

I've done something similar like you want to do. I created my 'base' images on my laptop with a basic installation of an OS using kvm and qcow2 image format. After that I just copied the images to our Hadoop cluster (with KVM installed) using scp. From then on I've been able to use the images without any problem to create virtual machines on the fly using that disk as a base. I imagine you can move your images using a USB stick too. Didn't have any problems in using my base images with KVM.

Kind regards,

Eric

dyasny 03-30-2012 08:35 AM

You didn't mention the configuration of the VMs at all.

Generally speaking, under libvirt, you need two things to export a VM - it's disk images and the xml definition file.
The latter can be easily obtained by running `virsh dumpxml $vmname > $myvm.xml` and the disk images are where you placed them, usually under /var/lib/libvirt/images unless you have defined them in a different way. If you are using LVM, you will need to dump the LV into a file using `dd` and dd that file into a new LV of the same size

Sydney 03-30-2012 08:59 AM

Thanks for the information I am going to test this move today. I will only be moving it off the server and then back in a different location, but it should be a good test. I will respond back after the test.

@dyasny Sorry your right, Host is SL 6.2 with the standard "use as VM host" install option. The guests are Ubuntu 8.10 Server 64 and Ubuntu 6.06 Server. Nothing is using LVM on these. I am unsure if this is enough detail, but if you are looking for something specific I would be happy to find it out and post it.

@dyasny & EricTRA Thanks for taking the time to look at my post. I have moved VMWare images physically off line, but never KVM and all my searches take me to doing migrations with NFS. Its a cool option just wont work in this case.If either of you could suggest a particularly good resource for learning and managing KVM that would be awesome. Of course you already replied to my OP so this would just be a cherry on top.

dyasny 03-30-2012 11:27 AM

Like everything Linux, KVM is just a small module. Besides you have qemu, libvirt, network and storage management stacks and higher end management solutions (like RHEV and oVirt).
So depending on what you are trying to achieve, different training paths can be found. After all, setting up a datacenter with hundreds of hosts running thousands of VMs is not the same as running a hypervisor on your laptop so you're able to run Excel once in a while

Sydney 03-30-2012 02:56 PM

Thanks, this question is answered. Here is the process I used derived from your answers:
Code:

    1. virsh dumpxml $vmname > $myvm.xml
    2. Backup $myvm.img file usually in /var/lib/libvirt/images
    3. Copy $myvm.img to new server
    4. Edit $myvm.xml
      1. I was changing the path to the Source File
          1. <source file='/var/lib/libvert/images/$myvm.img'/>
    5. virsh define $myvm.xml



All times are GMT -5. The time now is 06:51 AM.