Recently I ran out of storage space on a Citrix XenServer because a number of local virtual disks had become orphaned and deleting them proved to be a little difficult, so, I thought it might be useful to share what I found lest others suffer the same issue.
I think the problem occurred because I removed disks which were attached to some VMs which had been created from templates, because I was using them with Provisioning Server and had run the XenConvert stage to copy the hard disk to the vDisk. This was so I could test that they worked without local disks, but didn’t want to delete them in case there was a problem.
I found two methods – the “hard” way and the “easy” way. Guess which I found first?! ;)
From a console shell prompt run the command:
Note that vdi is short for “virtual disk image” in this context. This should result in a display similar to the following with one entry per storage item so will include ISO images as well as virtual disks. Note that this will list all items, not just orphaned ones. Pipe the output to “more” or redirect to a file and use “vi” or similar on the file produced to find the oprhaned items.
uuid ( RO) : cb5781e0-c6f9-4909-acd6-5fd4b509d117
name-label ( RW): Vista master for UIA
name-description ( RW): Created by template provisioner
sr-uuid ( RO): 72cc0d44-bea7-6c15-cf8d-c2965ca495b2
virtual-size ( RO): 25769803776
sharable ( RO): false
read-only ( RO): false
Fortunately, I knew the name of the disks that were orphaned so passed their uuid values as an argument to the “xe vdi-destroy” command thus:
xe vdi-destroy uuid=cb5781e0-c6f9-4909-acd6-5fd4b509d117
The storage space freed up by deleting the disks will eventually be realized but to force this, you can manually instigate a re-scan of the containing storage repository. For this, we need to know the uuid of the storage repository which we have in in the “sr-uuid” field in the original “xe vdi-list” command above:
xe sr-scan uuid=72cc0d44-bea7-6c15-cf8d-c2965ca495b2
Add the disk to an existing VM and then delete the disk from the “Storage” tab in XenCenter for the VM when it is powered down :)
I hope this is of use to someone?…