In this part of the series, we will configure two hosts as iSCSI initiators. The hosts have already been defined at the Target and ready to log on.
Both hosts are running WS 2012 Hyper-v Core and I made sure to install the Failover Clustering and Hyper-v windows features. Following is a snapshot of the cmdlets available the iSCSI PowerShell module. We will remote into Host A using the Enter-PSSession command PowerShell:
1) The first step is to start the iSCSI service. This will make the cmdlets available on the initiator host:
Start-Service -Name msiscsi (To start the iSCSI service on the initiator)
2) We will set the startup type for the service as auto. This keeps the service running in event of a restart:
Set-Service -Name msiscsi -StartupType Auto
3) Specify the iSCSI Target server:
New-IscsiTargetPortal -TargetPortalAddress 10.0.0.106 (Specify the iscsitarget server)
4) Connect to the referenced iSCSI Target using the following commands:
Get-IscsiTarget | Connect-IscsiTarget (Connect to the target)
5) Register the target. This keeps the connection to the target persistent in the event of a restart:
Get-IscsiSession | Register-IscsiSession (Register the iSCSI target as a favorite target to automatically reconnect after a host reboot)
6) After the last few steps, the virtual disk is presented to the host machine as a local disk but in an offline state. The following snapshot illustrates this:
As shown, the Get-Disk cmdlets displays a list of all disks attached to the host. The next screenshot shows a listing of all cmdlets supported by the storage module. These cmdlets will enable us complete the next set of tasks
We will now attempt to bring the disk into an online state, initialize, partition and format. The following cmdlets will help us accomplish these tasks:
Set-Disk -Number 1 -IsOffline $false (Sets the disk into an online state)
Set-Disk -Number 1 -IsReadOnly $false(Makes the disk writable)
Initialize-Disk -Number 1 -PartitionStyle mbr (Initializes the disk with an MBR PartitionStyle)
Get-Disk -Number 1 | New-Partition -UseMaximumSize | Format-Volume -FileSystem ntfs (These set of commands will partition and format the disk.)
The above steps could also be accomplished opening Server Manager on the Target Server, and navigating to the Disk Management utility GUI. The iSCSI target disk should appear visible and connected to Host A as a local volume. Still connected to Host A, use Disk Management to bring the new volume online, initialize it, and format using NTFS. Label the disk using the names of the VHDs/devices for name standardization.
Please note,do not assign a drive letter to this volume. You do not have to repeat the disk configuration steps on the second host in the proposed cluster. Logging into the other host will show the disk as visible. The disk will be in an offline state. Do not attempt to bring the shared disk online on the other host.