Working with iSCSI Target and Initiator to Mount on Clients

30 minutes
  • 5 Learning Objectives

About this Hands-on Lab

Being able to work with iSCSI block storage on servers and clients is becoming a common skill in today’s distributed IT organizations. This activity will allow you to get hands on with setting up both an iSCSI initator and target (client and server) in order to mount that block storage on a system. Once you have completed this activity, you will understand how to make iSCSI storage available and then consume it on a system.

Learning Objectives

Successfully complete this lab by achieving the following learning objectives:

Install the Server and Client iSCSI Utilities

Since we are using the single instance as both server and client (target and initiator in this case), we can install what is needed with:

sudo yum install -y targetcli iscsi-initiator-utils
Create the iSCSI Block Device on the Server

Using the first device on the system of 20gb, you are asked to create a block device that you make available via iSCSI. This will involve the following commands:

As root:

[#/] targetcli

/> backstores/block/ create test1 /dev/nvme2n1
/> iscsi/ create iqn.2018-11.com.mylabserver:t1
/> cd iscsi/iqn.2018-11.com.mylabserver:t1/tpg1
/> luns/ create /backstores/block/test1
/> acls/ create iqn.2018-11.com.mylabserver:client
Enable and Start the Target iSCSI Service

Easy enough to do, as root:

systemctl enable target
systemctl start target
Create the Client Initiator Name

We need to add the client initiator name (which we created in the earlier configration ACL for the target) to the /etc/initiatorname.iscsi file, like so:

 InitiatorName=iqn.2018-11.com.mylabserver:client
Complete the Client ‘Initiator’ Configuration and Discover (Verify) the Configuration

Within the /etc/iscsi/iscsi.conf file, you will look for, and change, the following values in the file:

node.session.auth.authmethod = CHAP
<CHANGE TO>
#node.session.auth.authmethod = CHAP

You are COMMENTING OUT the value. You then need to enable and start the service:

systemctl enable iscsi
systemctl start iscsi

Discover and verify you can now see the block device:

iscsiadm --mode discovery --type sendtargets --portal [Private IP of Server]

and you should see the target configured.

Restart the iscsi and iscsid services:

    systemctl restart iscsi
```
systemctl restart iscsid
```

Now make sure you can connect:

iscsiadm --mode node --targetname iqn.2018-11.com.mylabserver:t1 --portal [Private IP of Server] --login

You should now see the SCSI device (like /dev/sda) when executing the ‘lsblk’ command

Additional Resources

You will be provisioned the access credentials (Username, Password and IP Connection) for a CentOS 7 server that you will use as both iSCSI server and iSCSI client (for verification). Once you have logged into your server, open your Activity Guide for instructions on completing this activity.

What are Hands-on Labs

Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.

Sign In
Welcome Back!

Psst…this one if you’ve been moved to ACG!

Get Started
Who’s going to be learning?