Remove hanging VDI-s in XenServer CLI

Sometimes a process involving VM vdi can be interrupted and the VDI is left hanging. It cannot be removed in XenCenter. If you select a SR and go under Storage tab you may see virtual disks that have XenServer host as vrtual machine. It usually says “Control domain on host …”. There is a way to manually remove this virtual disk on the CLI console.

Find out the uuid of your hanging vdi:

xe vdi-list name-label=<vm name label>

Now show all volume groups:

vgs

In the response you should identify your SR volume group that the vdi is in. You can do this by looking at the VSize and VFree fields.

Now scan the volume group for vhd-s:

vhd-util scan -m "VHD-*" -f -c -l VG_XenStorage-<volume group id> -p –v

If you see your vhd there then you can now remove it:

lvremove /dev/VG_XenStorage-<volume group id>/VHD-<vdi uuid>

Now re-scan the SR in XenCenter and the hanging virtual disk should be gone.

3 thoughts on “Remove hanging VDI-s in XenServer CLI

  1. Niklas Ljung says:

    Thanks Yllar, but can I be sure the VDI is not deleted? I have our mailservers C:-disk detached from the VM and connected to “Control domain on host….” following a failed move operation. I’m really up sh*t Creek here 🙁 Any help much appreciated.

  2. Vit says:

    TNX. It’s really help for me. After unhapping export some VM, in SR created some Virtual Disk, and eat my space from Local Storage
    But for command was is:
    lvremove /dev/VG_XenStorage-/VHD- –config global{metadata_read_only=0}

    Xen Version 7.2

Leave a Reply

Your email address will not be published. Required fields are marked *

You must enable javascript to see captcha here!