1

We currently have a test environment where we create hundreds of LUNs on our SAN-attached storage array, export them to one or more (physical) servers, run tests on the data contained on the LUNs, then destroy them and repeat.

We would like to use VMs as the servers, but are having problems with assigning hundreds of LUNs manually to each individual VM (where as before with the physical servers, we could just setup the zoning to do this and do an HBA re-scan).

Any suggestions on how to handle this situation? One solution may be VM direct path IO (but we don't have the required hardware at the moment for that), or to setup a script to automatically re-scan for new LUNs at the ESX level and then automatically assign the LUNs to particular VMs (which I would assume could be done through an API?).

1 Answers1

1

I can't see why you shouldn't be able to do this with any standard ESX\ESXi setup.

You should be able to do it with Raw Device Mappings. Assuming the zoning and LUN presentation procedures on the SAN end remains unchanged you can use vmkfstools to tell ESX to rescan and detect the new LUNs at the host level. Once that is found you can then either create VMDK's and add them to the VM or present the entire volumes as Raw Device Mappings (RDM's).

With ESX you could script this on the Service Console command line but for ESXi you will need to use either the PowerCLI (Powershell) or the Perl CLI tools. The vSphere Management Appliance is a Linux appliance that has all of the tools pre-packed if you want to take that route. The documentation for all three CLI approaches can be found here.

The general outline of what you will want to do is:

1. Rescan for the new LUNs on the host.

vicfg-rescan [vmhbaX]   

You will probably just want to scan the relevant HBA's that the LUN is presented to so substitute vmhbaX with the relevant HBA names that are connected to your SAN.

2. Create an RDM stub that maps to the new LUN

vmkfstools –a lsilogic -r /vmfs/devices/disks/vmhba1:0:0:0 /vmfs/volumes/storage1/testluns/testrdmlun.vmdk

You will need to figure out the LUN reference for your LUNS and set the vmdk to a location and name that makes sense in your environment. There are a couple of syntax variants with this and I haven't used this on ESXi 4 but this format used to work fine for me on 3.5. There are two RDM modes, if you need more SCSI functionality then Raw Device Mapping Passthrough mode may be more appropriate for you, in that case replace the -r with a -x.

3. Present the new disk to your VM(s).

Once you have the disk prepared in this way there are a couple of ways to present these to the OS within the VM. You can edit the VM config and add an entry for this device, or you could have this specific target vmdk already configured in a VM and you could run through the above discovery steps while the VM was powered off. If you want a more dynamic mechanism the best way to do what you want to do would be to use the VMware Disk Mount utility - this allows you to directly mount the RDM (or any other VMDK) from within the guest OS without having to mess with the VM config.

If you are using the remote CLI for the rescan and vmkfstools parts you may have to specify the target host and authentication credentials as part of the commands.

The same approach could be used with standard VMDK files but you would need to format the LUN as a VMFS first and then create a suitable VMDK on it. As far as I can tell from your description there is no benefit to you to be gained from doing it that way.

Helvick
  • 19,579
  • 4
  • 37
  • 55
  • Great question and exactly the answer I'd have given too, although I may have used raw luns and formatted them as VMFS mid-way through as for me that would be a more appropriate test. I use the vMA all day every day and just love it. – Chopper3 Jan 23 '10 at 18:02
  • @Chopper - gotta agree - the vMA is an excellent feature and doesn't get nearly as much publicity as it should in my opinion. – Helvick Jan 23 '10 at 18:05