Difference between revisions of "Moving A Virtual Machine"

From Nuclear Physics Group Documentation Pages
Jump to navigationJump to search
(Created page with "Moving a virtual machine is not so difficult, BUT, you must be careful. == Simple Move == The recipe for a simple move. Assume a move from Taro to Gourd. In this case the Go...")
 
Line 7: Line 7:
 
On Taro:
 
On Taro:
 
<code>
 
<code>
 +
virsh destroy machine.name  # Shut down the old machine.
 
  virsh dumpxml machine.name  > /net/data/gourd/kvm/machine_clone.xml
 
  virsh dumpxml machine.name  > /net/data/gourd/kvm/machine_clone.xml
  virt-clone -o roentgen.unh.edu -n roentgen2.unh.edu -f /net/data/gourd/kvm/roentgen2.unh.edu.qcow2
+
  virt-clone -o original_machine_name -n new_machine_name -f /net/data/gourd/kvm/new_machine_storage.qcow2
 
</code>
 
</code>
  

Revision as of 20:48, 8 April 2015

Moving a virtual machine is not so difficult, BUT, you must be careful.

Simple Move

The recipe for a simple move. Assume a move from Taro to Gourd. In this case the Gourd data drive is accessible as /net/data/gourd. One could also have exported and then mounted /kvm on gourd.

On Taro:

virsh destroy machine.name  # Shut down the old machine.
virsh dumpxml machine.name  > /net/data/gourd/kvm/machine_clone.xml
virt-clone -o original_machine_name -n new_machine_name -f /net/data/gourd/kvm/new_machine_storage.qcow2

On Gourd:

# Move the xml file to correct location:
mv /data/kvm/machine_clone.xml /etc/libvirsh/qemu
# Edit the file to point to the new storage location.
emacs -nw /etc/libvirsh/qemu/machine_clone.xml
# Start machine
virsh define /etc/libvirsh/qemu/machine_clone.xml
virsh start machine.name

Yes, you end up with a small inconsistency in that the machine and virsh think correctly that the name is machine.name while to files are all machine_clone. This can be changed with a rename of the files. You can also keep it to remind you the machine was moved.