You can Watch all our Tutorials and Training Videos for Free on ourYouTube Channel

Configure iSCSI Target Server on Linux using TargetCLI

iscsiadm linux, iscsi on linux, ubuntu iscsi target, ubuntu iscsi initiator, linux iscsi server,iscsiadm commands,linux mount iscsi,targetcli command

configure iscsi target server

This post will show you How to Install and Configure iSCSI Target Server using targetcli on Linux.

If you are interested in learning, Request you to go through the below recommended tutorial.

In a SCSI Environment, there are two kind of iSCSI connecting types which are,

1. An iSCSI target which provides some storage space, this would be at server end.
2. An iSCSI initiator who access the provided space from storage at client end. This iSCSI initiator would be at Client end.

Our Scenario:

1. iSCSI Server :
2. iSCSI Client :

At Server End: iSCSI Target Congfiguration

iSCSI target configuration is done through the interactively targetcli command. This command uses a directory tree structures to access the different objects.

Configure iSCSI Target Server using targetcli on Linux

To create an iSCSI target server, we need to follow the below steps on the server.


Install the required Packages using YUM

If yum not configured, please go through this link How to Configure Local Yum Server
[root @learnitguide ~]#  yum install -y targetcli

Activate the target service at boot:
[root @learnitguide ~]#  systemctl enable target

Note: This is required to be enabled, otherwise your configuration won’t be read after a reboot!

Execute the targetcli command
[root @learnitguide ~]#  targetcli
Warning: Could not load preferences file /root/.targetcli/prefs.bin.
targetcli shell version 2.1.fb34
Copyright 2011-2013 by Datera, Inc and others.
For help on commands, type 'help'.

Creating Backstores

There is a two main options, fileio and block.

We will go with block backstores,

block backstore that usually provides the best performance. You can use a block device like /dev/sdb or a logical volume previously created.
/> backstores/block/ create mylun /dev/VolGroup00/lvol00
Created block storage object block1 using /dev/VolGroup00/lvol00.

Creating an IQN
/> iscsi/ create
Created target
Created TPG 1.
Global pref auto_add_default_portal=true
Created default portal listening on all IPs (, port 3260.

Now, we can go to the newly created directory.

Three objects have been defined under tpg1:

  1. acls (access control lists: restrict access to resources),

  2. luns (logical unit number),

  3. portals (define ways to reach the exported resources).
/iscsi/iqn.20...ple:t1/tpg1> portals/ create
Using default IP port 3260
Binding to INADDR_ANY (
Created network portal

Finally check the configuration using the command "ls" and quit from the targetcli session.
/iscsi/iqn.20...ple:tgt1/tpg1> exit
Global pref auto_save_on_exit=true
Last 10 configs saved in /etc/target/backup.
Configuration saved to /etc/target/saveconfig.json

Note: The configuration is automatically saved to the /etc/target/saveconfig.json file.

Also, it can be useful to check the ports currently used so we can confirm who accessing it.
[root @learnitguide ~]#  netstat -ant
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address           Foreign Address         State
tcp        0      0    *               LISTEN
tcp        0      0  *               LISTEN
tcp        0      0  *               LISTEN
tcp        0      0      ESTABLISHED
tcp6       0      0 :::22                   :::*                    LISTEN
tcp6       0      0 ::1:25                  :::*                    LISTEN

Finally, open the 3260 tcp port in the firewall configuration:
[root @learnitguide ~]#  firewall-cmd --permanent --add-port=3260/tcp

Reload the firewall configuration:
[root @learnitguide ~]#  firewall-cmd --reload

That's it, we are done with iSCSI target configuration at server end. Now we need to go to the client and access the lun as mentioned in our previous articles. Click here to see How to Access or Map an iSCSI LUN Volume on Linux Client.

Related Content on Linux might be useful to you to improve your Linux Skills.

Keep practicing and have fun. Leave your comments if any.

Support Us: Share with your friends and groups.

Stay connected with us on social networking sites, Thank you.
Cookie Consent
We serve cookies on this site to analyze traffic, remember your preferences, and optimize your experience.
It seems there is something wrong with your internet connection. Please connect to the internet and start browsing again.
AdBlock Detected!
We have detected that you are using adblocking plugin in your browser.
The revenue we earn by the advertisements is used to manage this website, we request you to whitelist our website in your adblocking plugin.
Site is Blocked
Sorry! This site is not available in your country.
whatsapp logo