locked
Issue with setting up an iSCSI initiator. RRS feed

  • Question

  • I am trying to get an iSCSI connection between two servers to work and have hit an issue. 

    I have two servers (SRV1, and FS1). SRV1 is the iSCSI target/server and FS1 is to be the client/initiator.

    To create the iSCSI target, I do this (on SRV1):

    # Install the iSCSI target feature on SRV1
    Install-WindowsFeature FS-iSCSITarget-Server
    # Create a folder on SRV1 to hold the iscis virtual disk
    $NIHT = @{
      Path        = 'C:\iSCSI' 
      ItemType    = 'Directory'
      ErrorAction = 'SilentlyContinue'
    }
    New-Item @NIHT | Out-Null
    # Create an iSCSI disk (that is a LUN):
    $LP = 'C:\iSCSI\SalesData.Vhdx'
    $LN = 'SalesTarget'
    $VDHT = @{
       Path        = $LP
       Description = 'LUN For Sales'
       SizeBytes   = 100MB
     }
    New-IscsiVirtualDisk @VDHT
    # Create the iSCSI target:
    $THT = @{
      TargetName   = $LN
      InitiatorIds = 'DNSNAME:SRV1.Reskit.Org'
    }
    New-IscsiServerTarget @THT
    # Create iSCSI disk target mapping:
    Add-IscsiVirtualDiskTargetMapping -TargetName $LN -Path $LP

    This works, however, when I go to use the target on FS1 get an issue.

    Here is the code:

    # Adjust and start the service on FS1
    Set-Service MSiSCSI -StartupType 'Automatic'
    Start-Service MSiSCSI
    # Setup portal to SRV1
    $PHT = @{
      TargetPortalAddress     = 'SRV1.Reskit.Org'
      TargetPortalPortNumber  = 3260
    }
    New-IscsiTargetPortal @PHT
    # Find and view the SalesTarget on portal
    $Target  = Get-IscsiTarget | 
                   Where-Object NodeAddress -Match 'SalesTarget'
    # Connect to the target
    $CHT = @{
      TargetPortalAddress = 'SRV1.Reskit.Org'
      NodeAddress         = $Target.NodeAddress
    }
    Connect-IscsiTarget  @CHT
    # Set up the disk
    Get-Disk | Where-Object BusType -eq 'iscsi'

    All the code seems to work except for the last line, where I use Get-Disk to get the iSCSI disks, and I get zero output. If I use just Get-Disk, this just returns the host's C: and not the iSCSI disk over from SRV1.

    How do I see the iSCSI disk? Clues as to what I am doing wrong?

    And - all best practice suggestions relating to the code fragments above would also be most welcome.


    • Edited by Thomas Lee Sunday, January 13, 2019 2:03 PM fixing grammerly crap!
    Sunday, January 13, 2019 1:33 PM

Answers

All replies

  • Hi,

    Thanks for posting in our forum.

    $THT = @{
    
      TargetName   = $LN
    
      InitiatorIds = 'DNSNAME:SRV1.Reskit.Org'
    
    }


    As far as I know, the InitiatorIds parameter should be FS1 instead of SRV1.

    If FS1 still cannot discover the target, please change InitiatorIds parameter to use IPaddress or IQN to see if it helps.

    InitiatorIds = "IPAddress:10.10.1.1"


    For your reference:

    https://docs.microsoft.com/en-us/powershell/module/iscsitarget/new-iscsiservertarget?view=win10-ps

    Best Regards,

    William


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    Monday, January 14, 2019 7:12 AM
  • A simple typo - {slaps head}!

    Thanks. The code now works great and we are using iSCSI.


    Thomas Lee <DoctorDNS@Gmail.Com>

    Monday, January 14, 2019 12:39 PM
  • Hi,

     

    I am glad to hear that your issue was successfully resolved. If there is anything else we can do for you, please feel free to post in the forum.

     

    Best Regards,

    William


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    Tuesday, January 15, 2019 2:45 AM