Select Page

Windows Server – Setting up iSCSI Target and Initiators v.1 

Setting up an iSCSI Target and iSCSI Initiator via PowerShell or GUI in Windows Server.

Setting Up iSCSI Target via PowerShell 

Log into the server that will be hosting our storage and open PowerShell. Once in PowerShell, run the following command to install the iSCSI Target Windows Feature: 

Install-WindowsFeature FS-iSCSITarget-Server 

Windows Server – Setting up iSCSI Target and Initiators 

Windows Server – Setting up iSCSI Target and Initiators

You will need a target Partition already online and ready before we can create a new iSCSI Virtual Disk. On the device we are doing to use for iSCSI storage, run the following PowerShell cmdlet: 

Get-Disk

Windows Server – Setting up iSCSI Target and Initiators

Using the number of the disk that we are going to use add that to the initialize-disk PowerShell cmdlet. 

Initialize-Disk –Number 1 –PartitionStyle GPT 

Windows Server – Setting up iSCSI Target and Initiators

Next we need to partition this new drive. Using Disk 1, we are going to assign it the drive letter of V and use the maximum drive size for our new partition. Use the following PowerShell cmdlet to accomplish this. 

New-Partition –DiskNumber 1 –DriveLetter V -UseMaximumSize 

Windows Server – Setting up iSCSI Target and Initiators

Windows Server – Setting up iSCSI Target and Initiators

Now we will format our volume V as NTFS. Use the following PowerShell cmdlet to complete this step: 

Format-Volume –DriveLetter V –FileSystem NTFS –Confirm:$false

Windows Server – Setting up iSCSI Target and Initiators

Windows Server – Setting up iSCSI Target and Initiators

With the new partition created, we can now create the iSCSI Virtual Disk. We are going to put it on the V drive in the folder iSCSIVirtualDisks and give it a size of 20 GB. 

New-IscsiVirtualDisk –Path V:\iSCSIVirtualDisks\LUN-2.vhdx -Size 20GB

Windows Server – Setting up iSCSI Target and Initiators

Windows Server – Setting up iSCSI Target and Initiators

Next, we are going to need to get some information from on our devices that is going to be using the iSCSI storage. On that device, log in and run the follow command in PowerShell: 

(Get-InitiatorPort).NodeAddress

Windows Server – Setting up iSCSI Target and Initiators

All three of them are the same in this example, so get down this information and log back into our iSCSI storage server. 

Using that information, we will now target each of our devices that will be using the iSCSI storage. Using the name lun2 and the InititatorIDs that we gathered in the previous step, run the following PowerShell cmdlet 

New-IscsiServerTarget lun2 –InitiatorIDs $InitIDs

Windows Server – Setting up iSCSI Target and Initiators

Windows Server – Setting up iSCSI Target and Initiators

Next we will need to map the Target Disk and the iSCSI Virtual Disk. Gathering together the Target Name of the LUN as well as the path used for the VHDX, running this PowerShell cmdlet  

Add-IscsiVirtualDiskTargetMapping –TargetName lun2 –Path V:\iSCSIVirtualDisks\LUN-2.vhdx -Size 20GB

Windows Server – Setting up iSCSI Target and Initiators

Windows Server – Setting up iSCSI Target and Initiators

On our target server we have one last step. That is to map the VHDX to our iSCSI destination device. Ensure that you give the –Lun parameter a unique ID. 

Windows Server – Setting up iSCSI Target and Initiators

 

Setting up iSCSI Target via GUI 

Log in to a Server you will be using to manage this process (with GUI and Server Manager). If you haven’t already, add the server we are going to use for storage. 

You will then need to install the iSCSI Target Server feature on that server. Checking this box will also check the File Server feature box as well. 

Once that is completed, reboot the target server. 

You will need a target Partition already online and ready. Should you need to create one, please use Computer Management or Server Manager and set one up before proceeding on the target server. 

When it is back online,  Open Server Manager go to File and Storage Services > iSCSI. 

Click on the Tasks drop down and select New iSCSI Virtual Disk.

Windows Server – Setting up iSCSI Target and Initiators

Now select the volume to use. This is the volume that you may have setup as a previous step above.

Windows Server – Setting up iSCSI Target and Initiators

Give it a name and a description. Note the path this will be stored on. 

Windows Server – Setting up iSCSI Target and Initiators

Give the new iSCSI Virtual Drive a size. In our case, we are going to use 200 GB of this space to create our iSCSI Virtual Disk and make it Dynamically expand based on usage. 

Windows Server – Setting up iSCSI Target and Initiators

Attach it to a LUN or create a new iSCSI Target. In this case we are going to attach it to a New iSCSI target. 

Windows Server – Setting up iSCSI Target and Initiators

Give the target name and a description. 

Windows Server – Setting up iSCSI Target and Initiators

Click Add under Specify access servers in order to Add our initiator server.

Windows Server – Setting up iSCSI Target and Initiators

We have multiple ways we can input that information. In this event we will browse AD and select the system that way (or you can enter the FQDN of the device). 

Windows Server – Setting up iSCSI Target and Initiators

Repeat the process to add each server you want to add as a iSCSI initiator (device that will use this virtual disk). This may happen for something like a cluster shared volume, but isn’t always the case depending on your use case. 

Windows Server – Setting up iSCSI Target and Initiators

Skip to Confirmation and then confirm all of the listed settings and click Create

Windows Server – Setting up iSCSI Target and Initiators

The wizard will run through and then show a successfully completed message. 

Windows Server – Setting up iSCSI Target and Initiators

You can now go the device via Computer Management or Server Manager and setup the drive. 

 

Setting up MPIO 

Adding MPIO to the Devices that are going to use iSCSI storage allows a high quality and reliable storage service with failover and load balancing capability. This plus the ability for more performance makes this essential for our iSCSI storage. 

On a device that will have iSCSI storage attached, login and type in mpiocpl.exe in the command line. 

Windows Server – Setting up iSCSI Target and Initiators

This will open MPIO Properties. We want to click on the Discover Multi-Paths tab, and then check the box to Add support for iSCSI devices and then click on Add. It will ask us to reboot for the changes to take affect. 

Windows Server – Setting up iSCSI Target and Initiators

Windows Server – Setting up iSCSI Target and Initiators

After the system has restarted, check back on the MPIO Devices tab and you should now see MSFT2005iSCSIBusType 0x9 (or similar ID) listed under Devices

Windows Server – Setting up iSCSI Target and Initiators

This process will need to be repeated for each of the devices that will be using the iSCSI storage. 

You may need to run these commands in order to set the proper MPIO defaults 

Enable MSDSMAutomaticClaim –BusType iSCSI 

Set-MSDSMGlobalDefaultLoadBalancePolicy –Policy RR 

 

Setting up iSCSI Initiator via PowerShell 

Log into a device that will be using the iSCSI storage. 

In PowerShell, we will start the iSCSI by typing Start-Service msiscsi 

Windows Server – Setting up iSCSI Target and Initiators

And will need to set the service to Automatic 

Windows Server – Setting up iSCSI Target and Initiators

Now we will need to connect back to our iSCSI Storage server using it’s IP Address or FQDN using the following PowerShell cmdlet: 

New-IscsiTargetPortal –TargetPortalAddress $Name 

If you have simply added a new LUN to an existing connection, you can run this PowerShell cmdlet to refresh the Portal: 

Get-IscsiTargetPortal | Update-IscsiTargetPortal 

Windows Server – Setting up iSCSI Target and Initiators

Windows Server – Setting up iSCSI Target and Initiators

To check if it was mapped, run the Get-iSCSITarget cmdlet. You should see a node address come up with a status of False under IsConnected. 

Windows Server – Setting up iSCSI Target and Initiators

By default, the new iSCSI target will be offline or not connected. To resolve this, we are going to connect our iSCSI target as shown here. You would replace the Target and Portal Address lines below with the IPs of those devices. 

Connect-IscsiTarget –NodeAddress $node –IsMultiPathEnabled $true –IsPersistent $true –TargetPortalAddress $iSCSIStorageServer –InitiatorPortalAddress $ServerConnectedtoStorage 

Windows Server – Setting up iSCSI Target and Initiators

Windows Server – Setting up iSCSI Target and Initiators

Repeat the above command for any other connections that will need to be made. 

 

Setting up iSCSI Initiator via GUI 

On a device that will have iSCSI storage attached, login and type in iscsicpl.exe in the command line. Should you be running this for the first time, you will get a message that the service is not running and a restart will be needed in order to finish initializing the service. 

Click Yes and restart the device. 

Windows Server – Setting up iSCSI Target and Initiators

Windows Server – Setting up iSCSI Target and Initiators

Once the device has restarted, log back in and open the iSCSI Initiator. Click on the Discovery tab and then on Discover Portal

Windows Server – Setting up iSCSI Target and Initiators

Enter the name of the server that is hosting the iSCSI storage, then click on OK. 

Windows Server – Setting up iSCSI Target and Initiators

You should now see the newly added target showing under Target portals

Windows Server – Setting up iSCSI Target and Initiators

Click on the Targets tab. Depending on if you have created any iSCSI Virtual Disks, or how many you have created, you may see different amounts. Click on our target and then click on Connect

Windows Server – Setting up iSCSI Target and Initiators

Check the Add the connection to the list of Favorite Targets, Enable multi-path and then click on Advanced

Windows Server – Setting up iSCSI Target and Initiators

Select Microsoft iSCSI Initiator from the Local adapter drop down list. Then select an IP address from the Initiator IP drop down list (Usually device you are on). Finally Select an IP address from the Target portal IP drop down list (Usually device where iSCSI storage is setup). You will need to ensure that the Initiator IP and the Target portal IP are within the same subnet.  

Click OK when you are done. 

Windows Server – Setting up iSCSI Target and Initiators

Under Discovered targets you should now see the status as Connected. We are now going to add the second connection for MPIO, so highlight our target and click on Properties

Windows Server – Setting up iSCSI Target and Initiators

In the Sessions tab, we should show one Identifier. To add the second, click on Add session

Windows Server – Setting up iSCSI Target and Initiators

Check the Add the connection to the list of Favorite Targets, Enable multi-path and then click on Advanced

Windows Server – Setting up iSCSI Target and Initiators

Select Microsoft iSCSI Initiator from the Local adapter drop down list. Then select an IP address from the Initiator IP drop down list (Usually device you are on). Finally Select an IP address from the Target portal IP drop down list (Usually device where iSCSI storage is setup). You will need to ensure that the Initiator IP and the Target portal IP are within the same subnet.  

Click OK when you are done. 

Windows Server – Setting up iSCSI Target and Initiators

You will now see both connections listed under Identifier

Windows Server – Setting up iSCSI Target and Initiators

And also see two targets under Favorite targets

Windows Server – Setting up iSCSI Target and Initiators

 

#EndofLine