HOME RESTORATION DIGITAL PHOTOS DIGITAL BOOKS PROFESSIONAL HISTORY CONTACT ME


CentOS 7 Creating an iSCSI Target (Part 1)

Domain name: example.com     Realm name: EXAMPLE.COM

Workgroup: EXAMPLE     Server IP address: xx.xx.xx.xx

Server name: linuxsvr01     Client name: linuxclnt01

Root password: ?Pa55w0rd!

We will use the logical volume iscsi01 (block level) so we can now configure our Target Server.

To do this we use targetcli which is normally installed by default.

To open targetcli issue the following command

# targetcli
targetcli shell version 2.1.fb41
    Copyright 2011-2013 by Datera, Inc and others.
    For help on commands, type 'help'.
/>

at the /> type cd + enter which will show this text interface

o- / .....................................................................[...]
  o- backstores ..........................................................[...]
  | o- block ..............................................[Storage Objects: 0]
  | o- fileio .............................................[Storage Objects: 0]
  | o- pscsi ..............................................[Storage Objects: 0]
  | o- ramdisk ............................................[Storage Objects: 0]
  o- iscsi ........................................................[Targets: 0]
  o- loopback .....................................................[Targets: 0]

use the arrow keys to navigate to | o- block and press enter to create and name our target

/backstores/block> create storage01 /dev/volume01/iscsi01

retype cd + enter and navigate o- iscsi and press enter to create a server iqn

/iscsi> create iqn.2016-04.com.example:serverhostname

this will not only create the iqn but will set the default portal 0.0.0.0:3260, so you need to change the portal to your server ip address, so navigate to

/iscsi/iqn.20...name/tpg1/portals> delete 0.0.0.0 3260

and then from the same point enter your server ip address

/iscsi/iqn.20...name/tpg1/portals> create x.x.x.x

it will automatically create the ip port 3260.

Now to create the lun for storage01, navigate to

/iscsi/iqn.20...name/tpg1/luns> create /backstores/block/storage01

Now we must allow our Windows iSCSI Initiator access to our target server, navigate to

/iscsi/iqn.20...name/tpg1/acls> create iqn.2016-04.com.example:clienthostname

In Windows the iqn is found on iSCSI Initiator in its properties configuration tab

By typing cd + enter we can check the complete configuration

o- / .....................................................................[...]
  o- backstores ..........................................................[...]
  | o- block ..............................................[Storage Objects: 1]
  | | o- storage01 .......[/dev/volume01/iscsi01 (1.4TiB) write-thru activated]
  | o- fileio .............................................[Storage Objects: 0]
  | o- pscsi ..............................................[Storage Objects: 0]
  | o- ramdisk ............................................[Storage Objects: 0]
  o- iscsi ........................................................[Targets: 1]
  | o- iqn.2016-06.com.example:serverhostname ........................[TPGs: 1]
  |   o- tpg1 ...........................................[no-gen-acls, no-auth]
  |     o- acls ......................................................[ACLs: 1]
  |     | o- iqn.2016-04.com.example:clienthostname ...........[Mapped LUNs: 1]
  |     |   o- mapped_lun0 .........................[lun0 block/storage01 (rw)]
  |     o- luns ......................................................[LUNs: 1]
  |     | o- lun0 ....................[block/storage01 (/dev/volume01/iscsi01)]
  |     o- portals ................................................[Portals: 1]
  |       o- x.x.x.x:3260 .................................................[OK]
  o- loopback .....................................................[Targets: 0]

If everything is OK save and exit

/iscsi/iqn.20...name/tpg1/acls> exit
    
Global pref auto_save_on_exit=true
Last 10 configs saved in /etc/target/backup.
Configuration saved to /etc/target/saveconfig.json

The configuration is saved, now we must start and enable the target service

# systemctl start target
# systemctl enable target

and allow the port on your firewall

# firewall-cmd --permanent --add-port=3260/tcp
# firewall-cmd --reload

All that is left to do is to configure Windows iSCSI Initiator by adding the ip address of the target server. We should now have a disk to initialize and format in Windows Disk Management.