Last active
August 9, 2017 07:03
-
-
Save tensorfields/4447653 to your computer and use it in GitHub Desktop.
Rename KVM guest VM
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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
instead of moving the img file, perhaps it is better to
# virsh vol-clone oldvolname newvolname --pool default
# virsh vol-delete oldvolname --pool default
that is, if you use virsh to manage your storage pool ...