After having problems with one of my Xenservers in my lab, I decided to build a SAN to store my VMs. After building the SAN, I created an iSCSI target and added it to the Xenserver pool. Next, I started moving a Windows 7 VM to the new SR, but changed my mind while it was copying. After I got the copy to cancel, I still had the virtual disk showing in the repository, and it was eating up space. When I went to delete it, the delete button was greyed out. I tried restarting the toolstack, but no luck.
So I guess it’s time to go to the command line. First thing I do is get the UUID of the VDI using the “xe vdi-list sr-uuid=611441f9-20c7-6775-716a-37c78b6d672e”. I get a list of VDIs and quickly find the uuid of the disk I want to delete.
uuid ( RO) : 203137f6-d98b-4e8e-8940-263e26360559
name-label ( RW): Win7-Image 0
name-description ( RW): DELETE
sr-uuid ( RO): 611441f9-20c7-6775-716a-37c78b6d672e
virtual-size ( RO): 25769803776
sharable ( RO): false
read-only ( RO): false
Now let’s try deleting with “xe vdi-destory uuid=611441f9-20c7-6775-716a-37c78b6d672e”. Result: The uuid you supplied was invalid. Whoops. Entered the SR uuid. Ok, let’s try this again. “xe vdi-destory uuid=203137f6-d98b-4e8e-8940-263e26360559“
This operation cannot be performed because this VDI is in use by some other operation
vdi: 203137f6-d98b-4e8e-8940-263e26360559 (Win7-Image 0)
operation: destroy
Eh boy. OK, so what is using it? When I’m looking at Xencenter, it shows the Virtual machine it is attached to is “Control domain on host xen1”, which is my first xenserver.
Next we need to look at the the virtual block devices that might be tying up this VDI by entering “xe vbd-list vdi-uuid=203137f6-d98b-4e8e-8940-263e26360559”. This should give you the result back similar to the following.
uuid ( RO) : fb58a7e8-6ad3-ed6b-05bb-817d6ff1e4f0
vm-uuid ( RO): 233c0fd0-1a4d-4746-8ae6-8d0bd642a145
vm-name-label ( RO): Control domain on host: xen1
vdi-uuid ( RO): 203137f6-d98b-4e8e-8940-263e26360559
empty ( RO): false
device ( RO): sm/backend/611441f9-20c7-6775-716a-37c78b6d672e/203137f6-d98b-4e8e-8940-263e26360559
Now, let’s delete that vbd so it releases the vdi by entering “xe vbd-unplug uuid=fb58a7e8-6ad3-ed6b-05bb-817d6ff1e4f0” followed by “xe vbd-destroy uuid=fb58a7e8-6ad3-ed6b-05bb-817d6ff1e4f0″.
You should now be able to delete the drive from Xencenter for from the command line.
I have a Virtual Disk that is not attached to any VMs and i would like to delete it off a NFS-backed SR, but the option for deleting it is grey’ed out. In the virtual disk list it says that it is attached to “Control domain on host: xen2″… there is no active tasks.
Perfect! Had a hard time finding a way to remove an old USB drive that I had attached to the Xenserver console to do a patch. This allowed me to unplug it from the control host and remove it from there, then actually remove the virtual device from the system. Thank you!
To give you an idea of what I was seeing and the process as indicated that worked:
(The old USB device no longer attached that I wanted to get rid of: 690b2454-db24-4216-a936-ba6a98dd2559)
(First error:)
[root@xenserver ~]# xe vbd-unplug uuid=690b2454-db24-4216-a936-ba6a98dd2559
The uuid you supplied was invalid.
type: VBD
uuid: 690b2454-db24-4216-a936-ba6a98dd2559
(Second error:)
[root@xenserver ~]# xe vdi-destroy uuid=690b2454-db24-4216-a936-ba6a98dd2559
This operation cannot be performed because this VDI is in use by some other operation
vdi: 690b2454-db24-4216-a936-ba6a98dd2559 (USB 6:0:0:0)
operation: destroy
(Actual solution:)
[root@xenserver ~]# xe vbd-list vdi-uuid=690b2454-db24-4216-a936-ba6a98dd2559
uuid ( RO) : 2b4e7f00-16d6-42f5-2a54-06d9edaecd65
vm-uuid ( RO): a7083bec-131a-4bdf-aba1-864c0c0aaad2
vm-name-label ( RO): Control domain on host: xenserver
vdi-uuid ( RO): 690b2454-db24-4216-a936-ba6a98dd2559
empty ( RO): false
device ( RO): sm/backend/5eb606ad-230a-b624-7989-23bacf05468e/690b2454-db24-4216-a936-ba6a98dd2559
(This was the uuid I first needed to unplug and destroy: 2b4e7f00-16d6-42f5-2a54-06d9edaecd65)
[root@xenserver ~]# xe vbd-unplug uuid=2b4e7f00-16d6-42f5-2a54-06d9edaecd65
[root@xenserver ~]# xe vbd-destroy uuid=2b4e7f00-16d6-42f5-2a54-06d9edaecd65
(Then I was able to destroy the “real” device that was bugging me:)
[root@xenserver ~]# xe vdi-destroy uuid=690b2454-db24-4216-a936-ba6a98dd2559
[root@xenserver ~]#
Very nice! Thanks!
YES! Thank you. There is nothing like being a Linux newbie on the job and finding the answers on your own. 🙂
I was sure to bookmark this page. LOL