Configuring iSCSI Target on Server 2012 Core


As you know, Server 2012 natively supports creating iSCSI targets. It’s great addition and i want to demonstrate how to set up this feature in core environment using only Powershell

My test equipment:

iSCSI Initiator –  Hyper-V VM on Server 2012
iSCSI Target – Intel Server System S1530SH with 2 SATA 500 Gb in RAID 1 and external RAID Controller with three different RAID 1.

It’s not very old server system but, comparing with newest server systems, it seems very slow during some tasks. Anyway, installation Server 2012 Datacenter Core takes about 6 minutes. Great? I think it’s pretty nice result.

Configuring iSCSI Server Target

1. Type powershell in the command line then Rename-Computer -NewName yourpcname -Restart . This cmdlet lets you change standard name of your server.
Also, i recommend to execute Update-Help cmdlet to get the latest help pages.

Rename-pc

2. After successful restart we need to configure ip parameters. Type Get-adapter to show all network adapters in your system and their status. Remember NIC’s Index number. For example, NIC with 12 looks to iSCSI , NIC with 13 – internal

get-netadapter

Changing ip properties at NIC with index 12

newNetIP

Type ipconfig /all to see result

3. Installing iSCSI Target feature. Type Get-WindowsFeature to see all available features in Server 8 and then Add-WindowsFeature FS-iSCSITarget-Server.

iSCSIfeatON

How to enable Windows Automatic Updates on Server Core?

4. Enabling Remote Desktop Services to management . However, you can use remote powershell connection

rdpON

5. Creating partitions and VHD on our disks

Get-Disk to see what disks are available in the system

get-disk

I have some old information on these disks, so i should run Clear-Disk -RemoveData to prepare them for new partitions and volumes

cleardisk

We have to initialize all disks before creation new partition using New-Partition cmdlet

newpartition

Formatting partition using Format-Volume cmdlet

formatpart

Creating Vitrual Disks on each partitions which we want to share through iSCSI Target New-iSCSIVirtualDisk c:\test\disk1.vhd -Description “test” -Size 10Gb

new-iscsivd

6. Setting up new iSCSI Target Server, disks mapping

New-iSCSIServerTarget testTarget -IntiatorIDs “IQN:iqn. … “

test – your target name, intitiatorID – client’s id to access target.

How can i get InitiatorID?

You have to use iscsicli command

iscsicl

Create Target : New-iSCSIServerTarget NameOfTarget -InitiatorIDs “IQN:iqn….”

newtarget

Mapping our VHDs to iSCSI Target

Add-iSCSIVirtualDiskTarget Test s:\test\disk2.vhd

vhdmapping

—————————–

Configuring iSCSI Initiator on the client machine

1. Starting iSCSI Intiator

startiSCSI

2. Connecting to created iSCSI Portal

New-iSCSITargetPortal -TargetPortalAddress YourTargetIP

con2targ

Get-iSCSItarget |FL   > shows your added target portal

gettarg

Connect-iSCSITarget -NodeAddress “your target IQN”

connecttargets

Get-Disk to see iSCSI disks. By default, they are in offline status

Get-DiskClient

Taking disks to online operational status using Set-Disk

takeonlinedisks

Finally, we’ll create new partitions and volumes. Notice , if your iSCSI disks are using for DPM Backups , it’s not necessary to create volumes. DPM can create them by itself.

New-Partition -DiskNumber _ -UseMaximumSize -DriveLetter _

UseMaximumSize lets to create partitions with the biggest size as possible.

newpart

Get-Partition -DiskNumber YourDisksNumbers | Format-Volume

format-volumes

Any questions or comments? Leave a reply!

7 thoughts on “Configuring iSCSI Target on Server 2012 Core”

  1. Really handy stuff! Thanks!

    Under the format volume I found it effective to just call the driveletter I just created like this:
    Invoke-Command -ComputerName NODE01 -ScriptBlock { Get-Partition -DriveLetter Q | Format-Volume -FileSystem NTFS }

    1. Paul, thx for your comment! This is the first one! Congratulations :). I’m really pleased!
      Invoke-Command is really helpfull . Espeсially in cases when we have a lot of servers. For example, “Invoke-Command -ComputerName (NameOfServers.txt) ..” gets server names from txt file and runs -ScriptBlock {PS cmdlets} remotely on each server..By the way, “Learn Windows PowerShell in a Month of Lunches”. is really nice book for learning and deep understanding ” for what ps we use”.

      Thanks again for comment. Don’t forget to follow me. It’s really inspiring!

  2. Dear all,
    I follow this step, but show read only message.

    Please help.
    Thanks.

    run this cmd from hyper server 2012 R2
    New-Partition -DiskNumber _ -UseMaximumSize -DriveLetter _

  3. I too am using this excellent post while working on a 2012 hyper v server core and have a “true” for the read only parameter. Your assistance is appreciated!!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s