Mapping VDIs directly to software iSCSI LUNs in XenServer

iscsilunnexentavdixenserver

I read in the XenServer Administrator's Guide in section 4.1.6.2 that you can map raw LUNs to VDIs if you're using a NetApp or EqualLogic SAN. Is it possible to do the same with Software iSCSI SANs (i.e. using a Nexenta/ZFS-based SAN as the iSCSI target)? I know I could setup an iSCSI SR and put VDIs on there, but I'd like to avoid it since I'd otherwise have to deal with the overhead of LVM, plus it'd make cloning more difficult. I'd handle the snapshotting and cloning from the SAN. So I'm basically just wanting to use a one-LUN-per-VDI mapping, without involving LVM inside the XenServer host.

I'm not opposed to setting this up through the CLI if necessary. I'd prefer something reliable that will persist across reboots of the XenServer host, but if I have to script something that will initialize the iSCSI sessions before the VMs start and the VDIs are loaded, I'm OK with that.

Best Answer

Figured it out. There is an undocumented "iscsi" SR driver that will create a LUN-per-VDI SR (I found this when looking through the /opt/xensource/sm directory - see the ISCSISR.py file). You can only set this up through the command-line, including creating the VBDs and attaching it to VMs. The VBDs and VDIs don't even show up in XenCenter.

Here's a sample command to set it up:

xe sr-create name-label=san type=iscsi device-config:target=<IP address of target> device-config:targetIQN=<IQN of target> shared=true

This will automatically create an VDI for each iSCSI LUN. If you end up adding a new iSCSI LUN on the SAN, XenServer will add a new VDI for it after executing the following command:

xe sr-scan uuid=<UUID of SR>

Also, if you end up resizing a LUN, XenServer does not automatically pick up on that, so you'd have to execute the following:

xe vdi-forget uuid=<UUID of VDI that you resized>
iscsiadm -m node -R
xe sr-scan uuid=<UUID of SR>

And to create a VBD and attach it to a VM:

xe vbd-create vm-uuid=<UUID of VM> device=<VBD device #, e.g. 0> vdi-uuid=<VDI of UUID>
Related Topic