For tests purposes, I replaced this FreeNas by Windows Server 2012 to take care of that part.
Note: Before writing this post, I grouped my physical disks together into a container called storage pools to manage those disks as a single storage space. Afterwards, in these storage pools, I created virtual disks (aka LUN) on which I specify a layout, ... which is simply a raid level.
OverviewIn the following post I will talk about the following points:
- Quick iSCSI Terminology
- Quick look at iSCSI Target Management (GUI and PowerShell iSCSI Modules)
- Installing the Windows Feature iSCSI Server Target (PowerShell)
- Creating a iSCSI Virtual Disk (aka LUN) (PowerShell)
- Creating a iSCSI Target and assigning it to one or more initiator(s) (PowerShell)
- Finding the iSCSI Qualified Name (IQN) (vSphere Client and PowerCLI)
- Assigning a iSCSI Virtual Disk (LUN) to a iSCSI Target (PowerShell)
Note: The iSCSI protocol is fully documented by the RFC 3720 and RFC 3721
iSCSI: iSCSI stands for Internet Small Computer System Interface.
It's an Internet Protocol (IP)-based storage networking standard for linking data storage facilities.
iSCSI is used to facilitate data transfers over a network (LAN, WAN or Internet) and transferring data by carrying SCSI commands over IP networks. iSCSI leverages the Ethernet network and does not require any specialized hardware
iSCSI Target Server: is the server that shares the storage, it runs the iSCSI Target. The server (machine) consumes the storage is called iSCSI initiator.
iSCSI Initiator: Typically, it is an application server. For example, iSCSI Target provides storage to a SQL server, the SQL server will be the iSCSI initiator in this deployment.
Target: It is an object which allows the iSCSI initiator to make a connection. The Target keeps track of the initiators which are allowed to be connected to it. The Target also keeps track of the iSCSI virtual disks which are associated with it. Once the initiator establishes the connection to the Target, all the iSCSI virtual disks associated with the Target will be accessible by the initiator.
iSCSI Virtual Disk: It also referred to as iSCSI LUN. It is the object which can be mounted by the iSCSI initiator. On Windows Server 2012, the iSCSI virtual disk is backed by the VHD file.
iSCSI Connection: iSCSI initiator makes a connection to the iSCSI Target Server by logging on to a Target. There could be multiple Targets on the iSCSI Target Server, each Target can be accessed by a defined list of initiators. Multiple initiators can make connections to the same Target. However, this type of configuration is only supported with clustering. Because when multiple initiators connects to the same Target, all the initiators can read/write to the same set of iSCSI virtual disks, if there is no clustering (or equivalent process) to govern the disk access, corruption will occur. With Clustering, only one machine is allowed to access the iSCSI virtual disk at one time.
IQN: iSCSI Qualified Name. It is a unique identifier of the Target or Initiator. The Target IQN is shown when it is created on the Server. The initiator IQN can be found by typing a simple "iscsicli" cmd in the command window or using Get-InitiatorPort in PowerShell
|Using PowerShell (module iSCSI) with the Cmdlet Get-InitiatorPort|
Briefly, the fields are:
- The string "iqn.", used to distinguish these names from "eui." formatted names.
- A date code, in yyyy-mm format that the naming authority took ownership of the domain
- The reversed domain name of the naming authority (person or organization) creating this iSCSI name. (com.lazywinadmin, com.example, com.google)
- An optional, colon (:) prefixing a storage target name specified by the owner of the domain name deems appropriate.
Loopback: There are cases where you want to run the initiator and Target on the same machine; it is referred as “loopback”. In Windows Server 2012, it is a supported configuration. In loopback configuration, you can provide the local machine name to the initiator for discovery, and it will list all the Targets which the initiator can connect to. Once connected, the iSCSI virtual disk will be presented to the local machine as a new disk mounted. There will be performance impact to the IO, since it will travel through the iSCSI initiator and Target software stack when comparing to other local IOs. One use case of this configuration is to have initiators writing data to the iSCSI virtual disk, then mount those disks on the Target server (using loopback) to check the data in read mode.
Quick look at iSCSI Target Management
The UI integrated to Service Manager
Once you installed the Windows Feature for iSCSI Target Server you will see a new menu under File and Storage Services
Windows Server 2012 comes with a complete set of PowerShell cmdlets for iSCSI. By combining the iSCSI target, iSCSI initiator, and storage cmdlets, you can automate pretty much all management tasks.
The module iSCSI is used for all iSCSI Initiator-specific Cmdlets and the iSCSITarget for all iSCSI target service-specific cmdlets.
iSCSI Cmdlets in Windows PowerShell
iSCSI Cmdlets in Windows PowerShell
Installation of iSCSI Target Server
In order to be able to use the Storage Features related to iSCSI, you will need to install the iSCSI Target Server Feature. This can be perform via the Server Manager Console but here I will only focus on PowerShell. You can find the UI procedure here
# Import the ServerManager PowerShell Module Import-Module -Name ServerManager
# Add the Windows Feature iSCSI Target Server Add-WindowsFeature -Name FS-iSCSITarget-Server
You might also want to install the iSCSITarget-VSS-VDS WindowsFeature too to be able to manage older application(s) that need VDS (Virtual Disk Service) and VSS (Volume Snapshot Service) to create volume shadow copies of data on iSCSI virtual disks. VSS is also used by some backup solutions. (more info)
# Add the Windows Feature iSCSI VDS/VSS Add-WindowsFeature -Name FS-iSCSITarget-VSS-VDS
Configuration of iSCSI Target Server
Again, here I'll use only PowerShell Cmdlets. You can find the UI procedure here
- Load the PowerShell iSCSI Module
- Create a iSCSI LUN (aka iSCSI Virtual Disk, a VHD file)
- Create a Target
- Assign the iSCSI LUN to the Target.
1 - Load the PowerShell iSCSI Module
This Module provides all iSCSI target service-specific cmdlets (see the list of Cmdlets in the screenshot above)
# Import the PowerShell Module iSCSITarget Import-Module -Name iSCSITarget
2 - Create iSCSI LUNHere we create a new iSCSI virtual hard disk (VHD) object with the specified file Path and Size.
# Create a 1GB iSCSI Virtual Disk New-IscsiVirtualDisk -Path c:\test\LUN1.vhd -Size 1GB
3 - Create a TargetHere we create a new iSCSI target object with the name "TestTarget1" specified by the -TargetName parameter. The -InitiatorIds parameter stores the initiators which can connect to the Target.
# Creating a iSCSI Target. I specify the IPAddresses of the Initiator Hosts (192.168.1.101 and 192.168.1.102) which are VMware vSphere Hosts. New-IscsiServerTarget -TargetName TestTarget1 -InitiatorId IPAddress:192.168.1.101,IPAddress:192.168.1.102
Optionally: Instead of the iSCSI Initiator's IPAddress you can also specify the IQN:
New-IscsiServerTarget -TargetName TestTarget1 -InitiatorId "IQN:iqn.1998-01.com.vmware:LAB1VH01-675d7f45"
Finding the IQN of your iSCSI Initator
Using VMware vSphere Client: You can find the IQN in the properties of your iSCSI Software Adapter.
I found two ways to get this information with PowerCli ...
1 - With Get-View (Call to the NET Framework)
((Get-view (Get-view -Id ((Get-VMhost lab1vh02.fx.lab).id)).config manager.storagesystem).StorageDeviceInfo.HostBusAdapter).iscsiName
2 - With Get-EsxCli
(Get-EsxCli -VMHost lab1vh02.fx.lab).iscsi.adapter.list()
4 - Assign the iSCSI LUN to the TargetHere we assign a virtual disk to an iSCSI target.
# Assigning the virtual disk to the iSCSI Target Add-IscsiVirtualDiskTargetMapping -TargetName TestTarget1 -Path C:\test\Lun1.vhd
|No output will be generated. |
There is no Passthru parameter either :-(
Optionally: You can specify the Logical Unit Number (LUN) associated with the virtual disk. By default, the lowest available LUN number will be assigned.
# Assigning the virtual disk to the iSCSI Target Add-IscsiVirtualDiskTargetMapping -TargetName TestTarget1 -Path C:\test\Lun1.vhd -Lun 25
Once a virtual disk has been assigned to a target, and after the iSCSi initiator connects to that target, the iSCSI initiator can access the virtual disk. All of the virtual disks assigned to the same iSCSI target will be accessible by the connected iSCSI initiator.
In my next post I will explain how to configure the iSCSI Initiator on VMware vSphere using PowerCli
- iSCSI Cmdlets in Windows PowerShell
- iSCSI Target Cmdlets in Windows PowerShell
- PowerCLI - Using Get-ESXCLI
- PowerShell Cmdlets for iSCSI Target
- Introduction of iSCSI Target in Windows Server 2012
- Managing iSCSI Initiator connections with Windows PowerShell on Windows Server 2012
- Setting up windows server 2012 storage virtualization. A software RAID solution or more
- Configure Windows Server 2012 as a ISCSI Storage Server
- Six Uses for the Microsoft iSCSI Software Target
Thanks for Reading! If you have any questions, leave a comment or send me an email at email@example.com. I invite you to follow me on Twitter: @lazywinadm