Tuesday, May 29, 2012

XenServer and "The VDI is not available"

I've been happily running XenServer for a few years now. Last week I encountered a weird issue with seemingly corrupted VDIs, which turned out to be fine after a server reboot.
In the aftermath I had a corrupted storage repository, that manifested like this:
  • Unable to scan the SR:
Error code: SR_BACKEND_FAILURE_46
Error parameters: , The VDI is not available [opterr=Error scanning VDI <uuid> ]
  • Unable to copy VDIs from or to the SR
    This was nasty, because this meant it wasn't possible to backup virtual disks.
After reading comments on the XenServer forums for many hours I found a working solution. First of all check the file /var/log/SMlog on the pool master server and then trigger a rescan of the bad SR. In my case I had a VDI with an invalid footer.
The log looks like this:
***** VHD scan error: vhd=VHD-<uuid> scan-error=-22 error-message='invalid footer'
*** vhd-scan error: <uuid>
Raising exception [46, The VDI is not available [opterr=Error scanning VDI <uuid>]]
I verified this by running
/usr/sbin/vhd-util scan -f -m "VHD-*" -l VG_XenStorage-<storage-reporitory-uuid> -p
Which, amongst others, gave me this line:
vhd=VHD-<uuid> scan-error=-22 error-message='invalid footer'
 Now many people recommended running vdi-forget to get rid of this VDI. I tried that, but that didn't fix anything. Others recommended running vdi-destroy. After I ran vdi-forget I wasn't able to run vdi-destroy anymore. So I had to work it out using lvremove like this:
lvremove /dev/VG_XenStorage-<storage-repository-uuid>/VHD-<uuid>
This gave me a few warnings like "open failed: Read-only file system" but in the end it did the trick. I re-scanned the storage repository and it finally worked. A few orphaned VDIs showed up which I promptly removed. Subsequent rescans of my SR coalesced VDIs without problems.

I found these links to be helpful: CTX122001 and Thread: Issue with reclaiming disk space in xenserver 6.0.

For the record, I'm running XenServer 5.6 SP2.

2 comments:

Anonymous said...

Thanks a LOT..!! mate.. this little note of yours saved the day for us.

anton van der leun said...

Thanks a lot, I reclaimed my "free" local SR completely.