Using an iSCSI target

Once you have an iSCSI target defined, as you did in the Creating an iSCSI target recipe, you can use it. Essentially, to use the disk, you connect to the iSCSI target server (that is, SRV1). Once you're connected, the Get-Disk cmdlet returns the iSCSI disk as though it were a local disk. You can then format and use the iSCSI disk as though it were local.

Getting ready

This recipe uses the iSCSI target you created in the Creating an iSCSI target recipe. You use SRV1 as the iSCSI target and access the target from the iSCSI initiator (FS1).

How to do it...

  1. On FS1, set the iSCSI service to start automatically, then start the service:
    Set-Service MSiSCSI -StartupType 'Automatic'
    Start-Service MSiSCSI
  2. Set up the portal to SRV1:
    $PHT = @{
      TargetPortalAddress     = 'SRV1.Reskit.Org'
      TargetPortalPortNumber  = 3260
    }
    New-IscsiTargetPortal @PHT
  3. Find and view the SalesTarget on the portal:
    $Target  = Get-IscsiTarget | 
                 Where-Object NodeAddress -Match 'SalesTarget'
    $Target
  4. Connect to the target on SRV1:
    $CHT = @{
      TargetPortalAddress = 'SRV1.Reskit.Org'
      NodeAddress         = $Target.NodeAddress
    }
    Connect-IscsiTarget  @CHT
  5. View the iSCSI disk on SRV1 from FS1:
    $ISD =  Get-Disk | 
      Where-Object BusType -eq 'iscsi'
    $ISD | 
      Format-Table -AutoSize
  6. Turn the disk online and set it to read/write:
    $ISD | 
      Set-Disk -IsOffline  $False
    $ISD | 
      Set-Disk -Isreadonly $False
  7. Create a volume on the iSCSI disk on FS1:
    $NVHT = @{
      FriendlyName = 'SalesData'
      FileSystem   = 'NTFS'
      DriveLetter  = 'I'
    }
    $ISD | 
      New-Volume @NVHT
  8. Use the drive as a local drive:
    Set-Location -Path I:
    New-Item -Path I:  -Name SalesData -ItemType Directory |
      Out-Null
    'Testing 1-2-3' | 
      Out-File -FilePath I:SalesDataTest.Txt
    Get-ChildItem -Path I:SalesData

How it works…

In step 1, you set the Microsoft iSCSI service to automatically start, then you start it. This step produces no output.

In step 2, you create a portal to the iSCSI server on SRV1, which looks like this:

How it works…

In step 3, you use the portal just created to get the SalesTarget iSCSI target on SRV1, which looks like this:

How it works…

In step 4, you connect to the iSCSI target on SRV1, which looks like this:

How it works…

Once you've connected to the iSCSI target, you can view the disk drive provided via iSCSI, which looks like this:

How it works…

In step 6, you turn the disk online and make it read/write. This step produces no output. In step 7, you create a new volume on this disk, which looks like this:

How it works…

In the final step, step 8, you use the iSCSI disk just like it was a local one, which looks like this:

How it works…

There's more...

This recipe enabled you to use the Microsoft iSCSI initiator to connect to a Microsoft iSCSI-provided target. These built-in features work and are fine for simple use.

The iSCSI initiator and the iSCSI target features with Windows Server 2019 have seen little development or improvement since they were first released over a decade ago. You may find independent third-party iSCSI vendors that are more appropriate depending on your requirements.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.135.206.254