Learn how to configure an iSCSI Target in Linux with our step-by-step guide. Set up a network storage solution to enhance your server’s storage capabilities efficiently. #centlinux #linux #iscsi
Table of Contents
What is iSCSI Target?
iSCSI (Internet Small Computer System Interface) is a protocol used to link data storage devices over an IP network infrastructure. An iSCSI target is often a dedicated network-connected hard disk storage device, but may also be a general-purpose computer. Nearly all modern mainstream server operating systems (such as BSD, Linux, Solaris or Windows Server) can provide iSCSI target functionality, either as a built-in feature or with supplemental software. The computer providing the iSCSI targets is called iSCSI Server.

What is iSCSI Initiator?
An iSCSI initiator is an iSCSI client. An iSCSI initiator typically serves the same purpose to a computer as a SCSI bus adapter would, except that, instead of physically cabling SCSI devices (like hard drives and tape changers), an iSCSI initiator sends SCSI commands over an IP network.
In this post, we will configure iSCSI Target in Linux, and then persistently mount that iSCSI Target on a iSCSI Initiator.
Recommended Training: The Linux Command Line Bootcamp: Beginner To Power User from Colt Steele

Read Also: How to Configure an iScsi Target in Openfiler
Linux Server Specification
We have provisioned two CentOS 7 virtual machines with following specifications.
iSCSI Server | iSCSI Initiator | |
Operating System: | CentOS 7 | CentOS 7 |
Hostname: | server1.example.com | desktop1.example.com |
IP Address: | 192.168.116.11/24 | 192.168.116.12/24 |
Apple 2024 Mac mini Desktop Computer with M4 chip with 10‑core CPU and 10‑core GPU: Built for Apple Intelligence, 16GB Unified Memory, 256GB SSD Storage, Gigabit Ethernet. Works with iPhone/iPad
$549.00 (as of May 17, 2025 16:12 GMT +00:00 – More infoProduct prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on [relevant Amazon Site(s), as applicable] at the time of purchase will apply to the purchase of this product.)Configure iSCSI Target
We have an spare hard disk (20 GB) is available. we have created a partition (20GB) in it using fdisk to make it usable by iSCSI Server.
fdisk -l /dev/sdb
Output:
Disk /dev/sdb: 21.5 GB, 21474836480 bytes, 41943040 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x94c52e45
Device Boot Start End Blocks Id System
/dev/sdb1 2048 41943039 20970496 83 Linux
we need targetcli package to configure an iSCSI Target.
yum install -y targetcli
Now obtain a targetcli shell.
targetcli
Output:
targetcli shell version 2.1.fb34
Copyright 2011-2013 by Datera, Inc and others.
For help on commands, type 'help'.
/>
Check the status of current iSCSI Target configurations.
ls
Output:
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]
/>
At the targetcli shell, create a Storage Block using following commands.
cd backstores/block/
create block1 /dev/sdb1
ls
Output:
Created block storage object block1 using /dev/sdb1.
o- block .................................................. [Storage Objects: 1]
o- block1 ....................... [/dev/sdb1 (20.0GiB) write-thru deactivated]
Create a TPG (Target Portal Group).
cd /iscsi
create iqn.2018-07.com.example.server1:remotedisk1
ls
Output:
Created target iqn.2018-07.com.example.server1:remotedisk1.
Created TPG 1.
o- iscsi .......................................................... [Targets: 1]
o- iqn.2018-07.com.example.server1:remotedisk1 ..................... [TPGs: 1]
o- tpg1 ............................................. [no-gen-acls, no-auth]
o- acls ........................................................ [ACLs: 0]
o- luns ........................................................ [LUNs: 0]
o- portals .................................................. [Portals: 0]
/iscsi>
Obtain the client iqn (iSCSI Qualified Name) from the client machine and use it to create an ACL, to limit the access to our iSCSI Target by desktop1.example.com machine.
cd /iscsi/iqn.2018-07.com.example.server1:remotedisk1/tpg1/acls
create iqn.1994-05.com.redhat:31532b60ee10
ls
Output:
Created Node ACL for iqn.1994-05.com.redhat:31532b60ee10
o- acls .............................................................. [ACLs: 1]
o- iqn.1994-05.com.redhat:31532b60ee10 ...................... [Mapped LUNs: 1]
o- mapped_lun0 .................................... [lun0 block/block1 (rw)]
/iscsi/iqn.20...sk1/tpg1/acls>
Create a LUN (Logical Unit Number).
cd /iscsi/iqn.2018-07.com.example.server1:remotedisk1/tpg1/luns
create /backstores/block/block1
ls
Output:
Created LUN 0.
Created LUN 0->0 mapping in node ACL iqn.1994-05.com.redhat:31532b60ee10
o- luns .............................................................. [LUNs: 1]
o- lun0 ........................................... [block/block1 (/dev/sdb1)]
/iscsi/iqn.20...sk1/tpg1/luns>
Create a Portal now.
cd /iscsi/iqn.2018-07.com.example.server1:remotedisk1/tpg1/portals
create 192.168.116.11
exit
Output:
Using default IP port 3260
Created network portal 192.168.116.11:3260.
Global pref auto_save_on_exit=true
Last 10 configs saved in /etc/target/backup.
Configuration saved to /etc/target/saveconfig.json
Allow the port 3260/tcp through firewall.
firewall-cmd --permanent --add-port=3260/tcp
firewall-cmd --reload
Start and enable the target service.
systemctl enable target
systemctl start target
iSCSI Target has been configured successfully.
RK ROYAL KLUDGE S98 Mechanical Keyboard w/Smart Display & Knob, Top Mount 96% Wireless Mechanical Keyboard BT/2.4G/USB-C, Hot Swappable, Software Support, Creamy Sounding, 98 Keys
$99.99 (as of May 17, 2025 16:11 GMT +00:00 – More infoProduct prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on [relevant Amazon Site(s), as applicable] at the time of purchase will apply to the purchase of this product.)Configure iSCSI Initiator
Install iscsi-initiator-utils package. It is required to configure a iSCSI Initiator.
yum install -y iscsi-initiator-utils
We can confirm the iSCSI Initiator’s iqn that, we have used during iSCSI Target configuration to create an ACL.
cat /etc/iscsi/initiatorname.iscsi
Output:
InitiatorName=iqn.1994-05.com.redhat:31532b60ee10
Start and enable iscsi service.
systemctl enable iscsi
systemctl start iscsi
Discover the available iSCSI Targets at 192.168.116.11.
iscsiadm -m discovery -t sendtargets -p 192.168.116.11
Output:
192.168.116.11:3260,1 iqn.2018-07.com.example.server1:remotedisk1
Restart iscsi service and list block devices.
systemctl restart iscsi
lsblk
Output:
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 20G 0 disk
ââsda1 8:1 0 300M 0 part /boot
ââsda2 8:2 0 1.5G 0 part [SWAP]
ââsda3 8:3 0 18.2G 0 part /
sdb 8:16 0 20G 0 disk
sr0 11:0 1 3.5G 0 rom /mnt/iso
Our iSCSI Target Disk has been successfully discovered as /dev/sdb. Let’s create a partition and the filesystem.
fdisk /dev/sdb
Output:
Welcome to fdisk (util-linux 2.23.2).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
Device does not contain a recognized partition table
Building a new DOS disklabel with disk identifier 0x08f4940d.
Command (m for help): n
Partition type:
p primary (0 primary, 0 extended, 4 free)
e extended
Select (default p):
Using default response p
Partition number (1-4, default 1):
First sector (8192-41940991, default 8192):
Using default value 8192
Last sector, +sectors or +size{K,M,G} (8192-41940991, default 41940991):
Using default value 41940991
Partition 1 of type Linux and of size 20 GiB is set
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
# fdisk -l /dev/sdb
Disk /dev/sdb: 21.5 GB, 21473787904 bytes, 41940992 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 4194304 bytes
Disk label type: dos
Disk identifier: 0x08f4940d
Device Boot Start End Blocks Id System
/dev/sdb1 8192 41940991 20966400 83 Linux
# mkfs.xfs /dev/sdb1
meta-data=/dev/sdb1 isize=256 agcount=16, agsize=327600 blks
= sectsz=512 attr=2, projid32bit=1
= crc=0
data = bsize=4096 blocks=5241600, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=0
log =internal log bsize=4096 blocks=2560, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
Now, persistently mount the partition at /mnt/remotedisk1.
echo "/dev/sdb1 /mnt/remotedisk1 xfs _netdev 0 0" >> /etc/fstab
mount -a
mount | grep /mnt/remotedisk1
Output:
/dev/sdb1 on /mnt/remotedisk1 type xfs (rw,relatime,seclabel,attr2,inode64,noquota,_netdev)
We have successfully configure iSCSI Target and then persistently mount it at our iSCSI Initiator.
Disarming Code: System Programming, Debugging & Reverse Engineering in Linux, Android, Darwin
Now retrieving the price.
(as of May 17, 2025 16:11 GMT +00:00 – More infoProduct prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on [relevant Amazon Site(s), as applicable] at the time of purchase will apply to the purchase of this product.)Final Thoughts
Configuring an iSCSI Target in Linux can significantly enhance your server’s storage capabilities by providing a robust and scalable network storage solution. By following this guide, you can set up and manage your iSCSI Target efficiently.
From setting up scalable AWS solutions to managing complex Linux environments, I’ve got you covered. Visit my Fiverr profile to get started.
Leave a Reply
You must be logged in to post a comment.