How to delete KVM Virtual machine using virsh

Deleting a KVM virtual machine using “virsh” is a multi-step process. You need to stop the virtual machine, find the storage device used by them VM, and remove the storage devices. Then undefine the virtual machine.

Here are the commands used to delete a KVM VM with the name win10.

First shutdown the VM

If it did not stop, you can force stop with the command

Find information about the VM with the command “virsh dumpxml –domain VM_NAME”

In the above result, you can see we are using the following storage device for this VM

This VM uses the storage device /dev/vg1/win10, we need to remove it.

The VM also uses ISO file /var/lib/libvirt/images/Win10_21H2_English_x64.iso, if you don’t need it, you can delete it.

To delete the VM, you can use

Example

Back to virsh

Need help with Linux Server or WordPress? We can help!

Leave a Reply

Your email address will not be published. Required fields are marked *