User Tools

Site Tools


virtualization:xenserver:xenserver_storage

XenServer Storage Notes

Examine

Show VDIs for a VM, then VDI details:

xe vdi-list | grep -B1 -A5 -i <part_of_vm_name>

xe vdi-list params=all uuid=<VDI-UUID>

Show VBDs for a VDI:

xe vbd-list vdi-uuid=<VDI-UUID>

Examine a VHD file:

Show SRs:

xe sr-list

ll /var/run/sr-mount/

Move a Storage Repository

Add a USB disk as a local SR

http://blogs.citrix.com/2010/10/18/how-to-add-a-usb-drive-to-citrix-xenserver-as-a-local-sr-storage-repository/

fdisk -l

ll /dev/disk/by-id/

xe sr-create type=lvm content-type=user device-config:device=/dev/disk/by-id/usb-<your-usb-device-name> name-label="Local USB Storage"

Expose Unattached VDIs

:!: Be careful! The last time I ran this, all disks were detached besides running VMs! 8-o

Run this command then rescan the SR to see if it illuminates deletion candidates:

for uuid in $(xe vdi-list sr-uuid=<SR-UUID> --minimal | tr ',' "\n"); do xe vdi-forget uuid=$uuid; done

xe sr-scan uuid=<SR-UUID>

Move or Copy a Virtual Disk to Another Repository

:!: Shut down the VM first.

:!: Using the GUI to do this can/will cause problems and is slower.

:!: Creating a full copy of a VM will also have the effect of consolidating all its virtual disks (parent-child).

:!: To move a VHD to a new SR, copy, attach, then delete the original when you are sure the new copy is working well.

xe sr-list
xe vdi-list sr-uuid=<uuid-of-source-sr>
xe vdi-copy uuid=<uuid-of-vdi> sr-uuid=<uuid-of-destination-sr>

xe sr-scan sr-uuid=<uuid-of-destination-sr>
xe vdi-list sr-uuid=<uuid-of-destination-sr>

Reset Disk Names

Here is a script to rename all virtual disks based on VM name:

http://run.tournament.org.il/xenserver-setting-virtual-disks-names-based-on-the-vm-names/

:!: Warning: this script will mess up your templates and any attached ISO images!

:!: Eject all ISO CD/DVD images before running this script.

:!: Only resort to using this script if things are really messed up.

:!: Consider making full backups of all VMs and deleting all snapshots first.

Script to Show XenServer Storage Relationships

#!/bin/bash
list=`/opt/xensource/bin/xe sr-list | grep uuid | awk -F: '{print $2}'`
for item in $list
do
echo "=================================================================="
echo "SR uuid=$item"
echo "=================================================================="
echo " "
/opt/xensource/bin/xe sr-list uuid=$item
echo "==========================================="
echo "List of underlying VDIs:"
echo "-------------------------------------------"
/opt/xensource/bin/xe vdi-list sr-uuid=$item
done

Recovering Disk Space

http://blogs.citrix.com/2012/05/03/creating-vms-from-templates-in-xenserver-creates-a-fast-clone/

:!: Widen your console display to see intended indentation indicating relationships.

:!: Check for long VHD chains which can affect performance and reliability.

At the XenServer CLI, you can see all VHDs with:

LVM Storage:

vhd-util scan -f -c -p  -m 'VHD-*' -l VG_XenStorage-<SR UUID>

NFS Storage:

vhd-util scan -f -c -p -m /var/run/sr-mount/<SR UUID>/*.vhd

If you see entries with “parent=VHD-xxxxxxxx-xxxx…” then you have VHDs with dependencies.

If you move/clone a VM to another LUN, only the last state of the VM will be copied and will therefore take less space there. After testing the copy, the original VM can be deleted so that all dependent VHDs will be gone.

:!: If you delete the template from the resource pool after fast cloning multiple VMs, the child becomes a full copy.

:!: Easy way to delete an orphaned disk: Attach it to a VM, then delete it.

Check for NFS Connectivity Issues

grep 'kernel: nfs: server [0-9.]* not responding, timed out' /var/log/messages
virtualization/xenserver/xenserver_storage.txt · Last modified: 2020/05/14 09:48 by gcooper