CentOS 7 Creating an iSCSI Client

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!

For this excercise you need another linux client (physical or virtual) and I am calling it clienthostname02. We need to install iscsi-initiator-tools as follows

# yum -y install iscsi-initiator-utils
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: mirrors.clouvider.net
 * extras: www.mirrorservice.org
 * updates: mirrors.clouvider.net
Package iscsi-initiator-utils- already installed and latest version
Nothing to do

The package is already installed because we chose the File and Storage Server add-on during CentOS installation.

Let us configure the iSCSI Initiator

# vi /etc/iscsi/initiatorname.iscsi
#This must be the same as set in any iSCSI target

As this is being done in a lab situation we are not authenticating via CHAP so there is no need to configure iscsid.conf. We can move on to discovering the target. Remember that x.x.x.x is the ip address of your target server.

# iscsiadm -m discovery -t sendtargets -p x.x.x.x
x.x.x.x:3260,1 iqn.2016-06.com.example:serverhostname

We can now login to the target

# iscsiadm -m node --login
Logging in to [iface: default, target: iqn.2016-06.com.example:serverhostname, portal: x.x.x.x,3260] (multiple)
Login to [iface: default, target: iqn.2016-06.com.example:severhostname, portal: x.x.x.x,3260] successful.

we can confirm the established session with

# iscsiadm -m session -o show
tcp: [1] x.x.x.x:3260,1 iqn.2016-06.com.example:serverhostname (non-flash)

On this linux client I had two physical devices /dev/sda (128 GB) and /dev/sdb (1 TB), therefore this iSCI device should be /dev/sdc 800 GB, let us confirm this with the command

# cat /proc/partitions
major     minor  #blocks  name
   8        0  125034840  sda
   8        1     512000  sda1
   8        2  124521472  sda2
   8       16  976762584  sdb
  11        0    1048575  sr0
 253        0   52428800  dm-0
 253        1    8257536  dm-1
 253        2   63766528  dm-2
   8       32  838860800  sdc

We can now create a logical volume as follows

# pvcreate /dev/sdc
# vgcreate iscsi_clienthostname /dev/sdc
# lvcreate -l +100%FREE -n iscsi_share iscsi_clienthostname

We now need to create a partition on the disk with the following command, inputs necessary are in red

# fdisk /dev/iscsi_clienthostname/iscsi_share
Command (m for help): n
Partition type:
   p   primary (0 primary, 0 extended, 4 free)
   e   extended
Select (default p): p
Partition number (1-4, default 1): enter to accept default
First sector (32760-1677688831, default 32760): enter
Using default value 32760
Last sector, +sectors or +size{K,M,G} (32760-1677688831, default 1677688831): enter
Using default value 1677688831
Partition 1 of type Linux and of size 800 GiB is set
Command (m for help):w to save and quit

Now to formatting using xfs file system

# mkfs.xfs /dev/iscsi_clienthostname/iscsi_share