Is it possible to rename KVM virtual machine? Yes, follow through this guide to learn how to rename KVM virtual machine with virsh command. virsh program is the main interface for managing virsh guest domains. The program can be used to create, pause, update and shutdown domains. It can also be used to list current domains.
Table of Contents
How to Rename KVM Virtual Machine with virsh command
So, have you created KVM Virtual Machines on your system and feel like the names assigned to them are not up to your taste? Worry not for this is how to simply rename that virtual machine.
Take for example, as in my case, your virtual machine is assigned a name like generic and you want to rename it to at least reflect the OS type name like cent-server. Well, lets have a look at how to.
Get the Name of the Virtual Machine
You can get the name of the virtual machine either from the Virt-manager or from command line using the virsh command;
virsh list --all
Id Name State --------------------------------- - mon01 shut off - vm01 shut off - generic shut off - stack shut off - win10 shut off
Shut down the Virtual Machine
Shutdown the Virtual Machine to be renamed.
sudo virsh shutdown generic
Generate VM XML File
Generate the xml configuration file of the VM to some file, say generic.xml in the current directory.
sudo virsh dumpxml generic > cent-server.xml
Rename the KVM Virtual Machine
Edit the generated xml file to rename the domain name between the name tags;
to your new VM name;
and the disk file in device section under
After making the changes, save the file and exit the xm file.
Undefine the Virtual Machine
Delete all the existing configurations of the Virtual Machine;
sudo virsh undefine generic
Recreate the Virtual Machine from the XML file
Create a new xml file for the Virtual Machine using the edited xml file.
sudo virsh define cent-server.xml
Finally, list all the Virtual Machines to confirm the changes.
sudo virsh list --all
Id Name State --------------------------------- - mon01 shut off - vm01 shut off - cent-server shut off - stack shut off - win10 shut off
And that that is all about renaming KVM virtual machine through a command line with virsh command.
That concludes our guide on how to rename KVM virtual machine with virsh command.