Skip to content

Instantly share code, notes, and snippets.

@eignatov
Forked from tensorfields/rename-kvm-guest.txt
Created July 1, 2014 13:27
Show Gist options
  • Select an option

  • Save eignatov/83dd56a2d16ae162e3cf to your computer and use it in GitHub Desktop.

Select an option

Save eignatov/83dd56a2d16ae162e3cf to your computer and use it in GitHub Desktop.
# Shutdown the VM and rename storage (optional)
$ virsh shutdown old_vm
$ mv /path/to/old_vm.img /path/to/new_vm.img
# Edit virsh template with the new name and storage
$ virsh dumpxml old_vm > new_vm.xml
$ vim new_vm.xml
~~~ new_vm.xml
<name>new_vm</name> # <-- change this line
...
<devices>
...
<disk type='file' device='disk'>
<driver name='qemu' type='raw'/>
<source file='/path/to/new_vm.img'/> # <-- change this line
<target dev='vda' bus='virtio'/>
...
</disk>
~~~
# Redefine the KVM guest
$ virsh undefine old_vm
$ virsh define new_vm.xml
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment