Windows 2022
Sponsored Link

iSCSI : Configure iSCSI Target2022/01/12

 
Configure iSCSI Target Server.
A storage on a network is called iSCSI Target, a Client which connects to iSCSI Target is called iSCSI Initiator.
[1] On CUI Configuration, Run PowerShell with Admin Privilege and Configure iSCSI Target Server.
Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.

# create iSCSI Target
# [-TargetName] : any Target name
# [InitiatorId] : specify Initiators to allow to connect to Target
# for specifying Initiators, possible to specify methods like follows not only IPAddress
# ⇒ IPAddress, IPv6Address, DNSName, IQN, MACAddress
PS C:\Users\Administrator> New-IscsiServerTarget -TargetName "iSCSITarget01" -InitiatorId @("IPAddress:10.0.0.110","IPAddress:10.0.0.111") 

ChapUserName                :
ClusterGroupName            :
ComputerName                : rx-7.srv.world
Description                 :
EnableChap                  : False
EnableReverseChap           : False
EnforceIdleTimeoutDetection : True
FirstBurstLength            : 65536
IdleDuration                : 00:00:00
InitiatorIds                : {IPAddress:10.0.0.110, IPAddress:10.0.0.111}
LastLogin                   :
LunMappings                 : {}
MaxBurstLength              : 262144
MaxReceiveDataSegmentLength : 65536
ReceiveBufferCount          : 10
ReverseChapUserName         :
Sessions                    : {}
Status                      : NotConnected
TargetIqn                   : iqn.1991-05.com.microsoft:rx-7-iscsitarget01-target
TargetName                  : iSCSITarget01

# create iSCSI virtual disk
# [-Path] : any PATH you'd like to create v-disk
# [-SizeBytes] : disk size
PS C:\Users\Administrator> New-IscsiVirtualDisk -Path "C:\iSCSIDisk\Disk01.vhdx" -SizeBytes 10GB 

ClusterGroupName   :
ComputerName       : rx-7.srv.world
Description        :
DiskType           : Dynamic
HostVolumeId       : {7B618CF5-8E74-4ED2-858A-78A97743E07D}
LocalMountDeviceId :
OriginalPath       :
ParentPath         :
Path               : C:\iSCSIDisk\Disk01.vhdx
SerialNumber       : B4038C72-8C4A-4F4F-9982-966BB22AE41A
Size               : 10737418240
SnapshotIds        :
Status             : NotConnected
VirtualDiskIndex   : 381244894

# assign iSCSI virtual disk to iSCSI Target
PS C:\Users\Administrator> Add-IscsiVirtualDiskTargetMapping -TargetName "iSCSITarget01" -Path "C:\iSCSIDisk\Disk01.vhdx" 

# enable CHAP for iSCSI Target and set Username and Password for authentication
# replace "username", "UserP@ssw0rd01" below to your username and password
# required password length over 12 chars
PS C:\Users\Administrator> Set-IscsiServerTarget `
-TargetName "iSCSITarget01" `
-EnableChap $True `
-Chap (New-Object PSCredential("username", (ConvertTo-SecureString -AsPlainText "UserP@ssw0rd01" -Force)))`
-PassThru 

# confirm settings
PS C:\Users\Administrator> Get-IscsiServerTarget -TargetName "iSCSITarget01" 

ChapUserName                : username
ClusterGroupName            :
ComputerName                : rx-7.srv.world
Description                 :
EnableChap                  : True
EnableReverseChap           : False
EnforceIdleTimeoutDetection : True
FirstBurstLength            : 65536
IdleDuration                : 00:05:07
InitiatorIds                : {IPAddress:10.0.0.110, IPAddress:10.0.0.111}
LastLogin                   :
LunMappings                 : {TargetName:iSCSITarget01;VHD:"C:\iSCSIDisk\Disk01.vhdx";LUN:0}
MaxBurstLength              : 262144
MaxReceiveDataSegmentLength : 65536
ReceiveBufferCount          : 10
ReverseChapUserName         :
Sessions                    : {}
Status                      : NotConnected
TargetIqn                   : iqn.1991-05.com.microsoft:rx-7-iscsitarget01-target
TargetName                  : iSCSITarget01

# restart service
PS C:\Users\Administrator> Restart-Service -Name WinTarget 
iSCSI : Configure iSCSI Target (GUI)
 
On GUI configuration, set like follows.
[2] Run Server Manager and Click [File and Storage Services] on the left pane.
[3] Select [iSCSI] on the left pane and then click [TASKS] - [New iSCSI Virtual Disk] on the right pane.
[4] Specify the server and volume for setting iSCSI disk. This example shows to configure a disk on a custom path (C:iSCSIDisk).
[5] Specify any name for virtual disk.
[6] Specify the disk size for virtual disk. For the selection of the type of disk, choose the one for your requirements.
[7] Specify the iSCSI Target to assign this virtual disk. If the Target is new, select like follows.
[8] Specify any name for iSCSI Target.
[9] Specify initiators (clients) to connect to this iSCSI Target. Click [Add...] button.
[10] Select a method to identify an initiator. This example shows to set initiators by IP address like follows.
[11] Configure authentication method between Target and Initiator. This example shows to configure CHAP like follows. If select CHAP, set username and password too that are used for connecting to Target from Initiator.
[12] If that's OK all, click [Create] button.
[13] After finishing creation, click [Close] button.
[14] A new virtual disk has been listed like follows.
Matched Content