How to create iscsi target on RHEL 5.6

In this post I will give short explanation how one can create iscsi target on RHEL 5.6. This process apply probably on all RHEL subversions ( at least RHEL5 and RHEL6 ), then all linux distributions which share same code tree as Red Hat ( Fedora, CentOS )
With small modification it will probably work for Debian ( comments are welcome and same procedure for Debian specific distributions )

iSCSI – internet SCSI – for better explanation take a look at Wikipedia, for more technical details about iSCSI please read at least 100 first hits returned by Google

In short iSCSI is a way how to connect storage space to your server without need to buy expensive Fibre SAN switches

To prepare iSCSI target when RHEL 5.6 is used you will need to install scsi-target-utils package

# yum install scsi-target-utils

Start tgtd service and ensure it starts on boot

# chkconfig tgtd on; service tgtd start

It will install some other packages it depends on, but here we do not need to pay attention about that.

Once scsi-target-utils is installed you have all necessary to start with preparation of your disk ( storage area ) to be iscsi target. In this example I am going to use 1.5 GB partition for this.

Before you proceed further, I would recommend you to read

# man tgtd

Ok, you already read it, so let’s proceed 🙂

First find you device blkid you want to use for iscsi target

# blkid

will give you list of all block devices present on your system

First it is necessary to assign iscsi target name

# # tgtadm –lld iscsi –op new –mode target –tid 1 –targetname

iscsi-target naming follows special procedure

iscsi target names are usually in format


We will use iqn — iSCSI qualified name

eqn — is enterprise qualified name [ for more information about iqn and eqn consult Google 🙂

[ after every action you can see results of your work if you run :
[ tgtdadm –lld iscsi –op show –mode target ]

Next step, create your logical unit

# tgtadm –lld iscsi –op new –mode logicalunit –tid 1 –lun 1 -b /dev/DISK

Here as /dev/DISK should be your desired disk — the future iscsi target space

Bind new target to network interfaces

# tgtadm –lld iscsi –op bind –mode target –tid 1 -I ALL

And we are almost done

Save configuration to be available after reboot

# tgt-admin –dump > /etc/tgt/targets.conf

And that is, you have iscsi target ready.

If you have iptables disabled [ do not do that, do not disable iptables on your linux box ], then next step is not importan for you. If you are responsible and your iptables rules are in place, then you will need to open port 3260, and in [default] iptables script enter below iptables rule

INPUT -m state –state NEW -m tcp -p tcp –dport 3260 -j ACCEPT

to test it first, run from command line

# iptables -A INPUT -m state –state NEW -m tcp -p tcp –dport 3260 -j ACCEPT

That is, your iscsi target is ready for use

To access it from another RHEL 5.6 machine, you will need to install iscsi-initiator-utils

# yum install iscsi-initiator-utils

and run below commands

# iscsiadm -m discovery -t st -p IP-address-of-iscsi-target

# iscsiadm -m node -T [ what return above command ] -p IP-address-of-iscsi-target -l

Now you should have your iscsi target disk exported and you can use it as any other disk space

Enjoy iscsi 🙂