How to delete KVM VM guest using virsh command

www‮tual.‬turi.com
How to delete KVM VM guest using virsh command

To delete a KVM virtual machine (VM) guest using the virsh command, you can use the following steps:

  1. Shut down the VM: First, you will need to shut down the VM. You can do this using the virsh shutdown command. For example:
virsh shutdown <vm name>

Replace <vm name> with the name of the VM you want to shut down.

  1. Undefine the VM: Once the VM is shut down, you can use the virsh undefine command to remove the VM's definition from the libvirt configuration. For example:
virsh undefine <vm name>

Replace <vm name> with the name of the VM you want to undefine.

  1. Delete the VM's disk image: Finally, you will need to delete the VM's disk image from the file system. The location of the disk image will depend on how you set up the VM. You can use the rm command to delete the file. For example:
rm /path/to/vm/disk.img

Replace /path/to/vm/disk.img with the path to the VM's disk image.

Keep in mind that these steps will delete the VM and all of its data. Make sure you have a backup of any important data before deleting the VM.

Created Time:2017-10-28 21:39:01  Author:lautturi