Every IT industry needs storage for saving the increasing data day by day. There are different methods by which we can provide storage to our client servers like through SAN, NAS, DAS, iSCSI, etc. In this tutorial, we are going to learn how to share storage from the main server to the client machine using iSCSI target in Red Hat Enterprise Linux 7 (RHEL 7).
Via Scsi Command
Rather than send these commands directly to the device they are sent via a SCSI transport which is assumed to contain a SCSI to ATA Translation (SAT) Layer (SATL). The SATL may be in an operating system driver, in host bus adapter firmware or in some external enclosure. Since SCSI uses a low-voltage differential (LVD) bus, a method where data is transmitted by comparing the difference in voltage between a pair of wires, its speed and cable lengths are limited. As a result, SCSI is now largely implemented via serial communications like Serial Attached SCSI (SAS), which offers significantly higher performance.
Sharing the storage through iSCSI (Internet Small Computer System Interface) is very economical and any machine can become target i.e. server which will provide the storage. This is a software based technique to provide storage to the client servers and requires “targetcli” rpm. And if you are preparing for RHCE exam, this is one of the objectives of the exam.
Basically, in this tutorial, we will learn how to configure or setup an iSCSI target using targetcli in RHEL7 or CentOS 7.
Step by Step Procedure to setup an iSCSI target in RHEL 7
1. First of all, verify if you have targetcli RPM or not. If not install it using OS native commands. We had the package already so it updated it using repo.

2. Now once the targetcli package is installed, enable and start it. Enable will make sure target service is active after every reboot.
3. Now add permanently iSCSI port 3260 to the firewall rule using the below commands and reload firewalld service.
Note: You won’t be able to see the port 3260 until you reload the firewalld service.
4. Now create a partition of the disk and set the size which you are going to share. You can also share a complete disk. Here, for example, we are creating 200MB partition with id “8e” for LVM and will create a logical volume (lv) with it.
Now you have to set configure your target and share the disk to the client. This is where actual work begins and should be done very carefully. We will use ‘targetcli’ command and then follow the steps given below.

5. Enter command ‘targetcli’ to get an iSCSI CLI prompt.
6. Now, use the logical volume (/dev/iscsi_vg/iscsi_lv) created in step 4 to create a block storage object ‘iscsi_disk’.
7. Then, create an IQN (iSCSI Qualified Name) called iqn.2018-06.com.server:client1.disk1. This will also create a default TPG (Target Portal Group).
If default portal is created, like above one, delete it. We will create a new one later.
Via Scsi Device

8.Now, we will create an ACL in the TPG.
This ACL configures the target to only accept initiator connections from a client presenting iqn.2018-06.com.server:client2 as it’s initiator IQN, also name as initiator name.
9. Create a lun for each backstores, here we have only 1 backstores, so we will create only 1 lun. This steps also activates the corresponding backstores.

10. Now create a portal to designate the listening IP address and ports. The IP given below is the IP of the client where you want to provide the storage.
The whole configuration should look like below. After that, you can exit the targetcli prompt.
Via Scsi Usb
11. Now, just restart the target service.
Via Scsi Interface
This was all about configuring your iSCSI target or iSCSI server and sharing to the client or iSCSI initiator. Hope you were able to understand and follow the steps. In case of any questions or doubt, please comment below. In the next article, we will see how to setup iSCSI initiator and mount the filesystem. So do not forget to subscribe our blog.
In case you like this article, please share it on your social media.
