Re: Deleting a KVM virtual machine from the command line

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]



> Did you try:
>
> virsh undefine  domain-id
>
> where domain-id is your vm name

Perfect, thanks Earl!  Here's the script in case anyone else might
find it useful.  Please post any improvements if you can see a way to
improve it.

#!/bin/bash
# Removes all KVM virtual machines from this host

# First destroy all running VMs
for i in $(virsh -q list | awk '{ print $2 }'); do
  virsh destroy $i;
  virsh undefine $i;
done;

# Next we delete their virtual disk images
rm -rf /var/lib/libvirt/images/*.img
_______________________________________________
CentOS mailing list
CentOS@xxxxxxxxxx
http://lists.centos.org/mailman/listinfo/centos



[Index of Archives]     [CentOS]     [CentOS Announce]     [CentOS Development]     [CentOS ARM Devel]     [CentOS Docs]     [CentOS Virtualization]     [Carrier Grade Linux]     [Linux Media]     [Asterisk]     [DCCP]     [Netdev]     [Xorg]     [Linux USB]
  Powered by Linux