5 minute read

I recently switched the backend storage of my VMware vSphere 5.1 Home Lab from FreeNas (OS based on UNIX) to iSCSI (Windows Server 2012 Storage Feature). The reason is that I wanted to play with the PowerShell iSCSI modules and do some tests with SMB v3.0.

In a previous post I showed how to create an iSCSI target using PowerShell on Windows Server 2012. Today I will demonstrate how I set the VMware vSphere 5.1 Software iSCSI Adapter using PowerCli and create the datastore using the LUNcreated in my previous post. I won’t cover how to assign the iSCSI traffic to a dedicated PortGroup and dedicated NICs.

Overview

In the following post I will cover the following points:

  • Terminology

  • PowerCli

  • Configuring the iSCSI Initiator on VMware vSphere 5.1

  • Turn On the iSCSI Initiator

  • Add a new iSCSI Target Address

  • Refresh HBA / Rescan Datastores

  • Creating a new Datastore using the presented iSCSI Lun

  • Find the lun Canonical Name

  • Create the new Datastore

  • Note on creating small LUN (<1GB)

  • GUI/VMware vSphere Client

  • Configuring the iSCSI Initiator on VMware vSphere 5.1 (step by step)

  • Creating a new Datastore using the presented iSCSI Lun(step by step)

iSCSI Target Initiator
Quick overview of my iSCSI Lab architecture

Terminology

iSCSI Target/Initiator/IQN… : Please check myprevious post.

HBA:A Host Bus Adapter (HBA) is a circuit board and/or integrated circuit adapter that provides input/output (I/O) processing and physical connectivity between a server and a storage device.

LUN:A Logical Unit Number (LUN) is a unique identifier used to designate individual or collections of hard disk devices for address by a protocol associated with a SCSI, iSCSI, Fibre Channel (FC) or similar interface. LUNs are central to the management of block storage arrays shared over a storage area network (SAN). LUN VMFS:VMware® vStorageVirtualMachineFileSystem (VMFS) is a high-performance cluster file system that provides storage virtualization optimized for virtual machines.It is a prerequisite when you wish build your virtual infrastructure using vmware, as default storing system for virtual machine files on shared storage as Fibre Channel and iSCSI SAN disks and partitions. The current version of VMFS is VMFS 5.

VMFS
source

Using POWERCLI

Configuring the iSCSI Initiator on VMware vSphere 5.1 (PowerCli)

Pre-requisites In order to work with the PowerCli cmdlets, you will need to load the PowerShell Snapin VMware.VimAutomation.Core. ``` # Load PowerCli Cmdlets Add-PSSnapin VMware.VimAutomation.Core # Connect to my VMware vCenter or your VMware host # I will get prompted for Credential Connect-VIServer lab1vh02.fx.lab -Credential (Get-Credential) ``` ```

Turn On the iSCSI Initiator To be able to connect to the iSCSI Target Server and see the target, you will need to enable the iSCSI Software Adapter on each of your host ``` ``` # Turn on the iSCSI Initiator on my VMware vSphere host (lab1vh02.fx.lab) Get-VMHostStorage -VMHost lab1vh02.fx.lab | Set-VMHostStorage -SoftwareIScsiEnabled $True ``` ``` ``` ``` ``` ```

Add a new iSCSI Target Address Then set the IP Address of the iSCSI Target Server to be able to connect to the iSCSI Targets ``` ``` ``` ``` # Set the iSCSI Target Server (192.168.1.10) on my VMware vSphere Host (lab1vh02.fx.lab) Get-VMHostHba -VMHost lab1vh02.fx.lab -Type iScsi | New-IScsiHbaTarget -Address 192.168.1.10 ``` ``` ``` ```

Refresh HBA / Rescan Datastore Finally you will need to rescan the HBA and VMFS volumes in order to be able to add the new datastore(s). ``` ``` # Performs a Rescan on all HBAs and VMFS volumes Get-VMHostStorage -VMHost lab1vh02.fx.lab -RescanAllHba Get-VMHostStorage -VMHost lab1vh02.fx.lab -RescanVmfs ``` ### Creating a new Datastore on the presented iSCSI LUN (PowerCli)

Find the Lun Canonical Name ``` To create a datastore using the New-Datastore cmdlet you will need to get the CanonicalName property from the Lun you want to use. ``` ``` ``` ``` # Get the iSCSI LUN presented to this server where Microsoft is the vendor Get-ScsiLun | Where-Object Vendor -like "MSFT" ``` ``` # Get only the Lun and store it in the $lun variable $lun = Get-ScsiLun | Where-Object {(($_.Vendor -like "MSFT") -and ($_.CapacityGB -eq 10))} ``` ``` ``` ```

Create the new Datastore # Finally create the datastore using the Lun ``` ``` New-Datastore -Vmfs -Path $lun.CanonicalName -Name Lun1 ``` Note: Using the GUI you cannot create datastore smaller than 1.3 GB (You'll see the error a bit later in this post). However with PowerCli YOU CAN !!! Anyway it's kind of useless to have a datastore as small as 1GB... ### Using the GUI/VMware vSphere Client ### Configuring the iSCSI Initiator on VMware vSphere 5.1
1 - On your VMware Host, select the tab Configuration, Storage Adapters and click on Add... 2 - Here leave the "Add Software iSCSI Adapter" option and click OK 3 - A warning message will show, click OK : "A new software iSCSI adapter will be added to the Storage Adapters list. After it had been added, select the software iSCSI adapter in the list and click on Properties to complete the configuration."
You'll see the following message while the Software iSCSI Adapter is being added...
Once added, you'll see the iSCSI Software Adapter with the iSCSI IQN of this server
4 - Right click on it and select Properties 5 - You'll see the message "A rescan of the host bus adapter is recommended for this configuration change. Rescan the adapter?". Click Yes
You'll see the above activities in the vsphere client activities window.
6 - Select the Dynamnic Discovery tab and click Add... in the Send Targets area. Enter the iSCSI Server (which is my Windows Server 2012 Server (192.168.1.10) in my case) and leave the default Port 3260. Click OK and click Close to continue.
In the detail window, you will see the LUN we created on Windows Server 2012.
Note: When we created the Virtual Disk/LUN, we could specify a LUN ID, this would show here.
### Creating a new Datastore on the presented iSCSI LUN In my previous post I created a 1GB Lun which was too small for the following procedure. If you do, you'll get the following error message on the final step. Towork-around this problem, use PowerCli ! Refer to "Creating a new datastore" above in this post.
Error: The Capacity value must be at least 1.3 GB. Enter another value. So I used a 10GB LUN for the following steps... 1 - In the Configuration tab of your VMware host, select Storage and Click on Add Storage 2 - In the Add Storage Wizard, select Disk/Lun and click Next 3 - Select a Disk/LUN to create a datastore, here I select my 10GB lun. Click Next. 4 - Specify the version of the VMFS for the datastore. Select VMFS-5 and click Next. Note: The table below depicts the most significant architectural changes for VMFS-5 in comparison to VMFS-3.
VMFS
Source
5 - Review the current disk layout. Click Next. 6 - Specify the datastore name. Click Next. 7 - Specify the maximum file size and capacity of the datastore. Here select the Maximum available space. click Next. 8 - Final step, review the disk layout and click Finish to end the Add Storage wizard.
Activity window show the creation of the VMFS datastore.
Once created, the lun will be available in "Storage"
### References * VMFS -[http://www.vmware.com/files/pdf/VMware-vStorage-VMFS-DS-EN.pd](http://www.vmware.com/files/pdf/VMware-vStorage-VMFS-DS-EN.pdf)

Leave a comment