To delete a VM and its corresponding storage: (Use with caution you are deleting all the associated storage)
# virsh undefine --domain {VM_NAME_HERE} --remove-all-storage
To delete the snapshots too:
# virsh undefine --domain {VM_NAME_HERE} --delete-snapshots --remove-all-storage
Another safer approach is
# virsh list --all
# virsh dumpxml {VM_NAME_HERE} // get the corresponding image.
# virsh undefine --domain {VM_NAME_HERE}
# rm -rf /path/to/image
I faced a error like this:
error: Refusing to undefine while domain managed save image exists
First run this command:
sudo virsh managedsave-remove --domain <domain name>
Next:
# virsh undefine --domain {VM_NAME_HERE} --remove-all-storage
If you face error saying "cannot define domain with nvram" use --nvram with above command.
# virsh undefine --nvram --domain {VM_NAME_HERE} --remove-all-storage
source: https://www.cyberciti.biz/faq/howto-linux-delete-a-running-vm-guest-on-kvm/
No comments:
Post a Comment