Arv tech           Home Page


How set up iSCSI Target in RHEL5

 

At the time of writing this article RHEL5 does not have native iSCSI target support or an RPM from Red Hat and must be built from source. At the time of writing this article iSCSI target version 0.4.15 was used.

 

The latest version of the iSCSI Target software can be downloaded here.

http://sourceforge.net/project/showfiles.php?group_id=108475

 

The following RPM packages must be installed or else compiling and installing the iSCSI target software will fail to install.

Perquisite Packages Must be Installed

kernel-devel

openssl-devel

gcc

Easiest way to install the above packages is to use yum.

yum -y install kernel-devel openssl-devel gcc

Here are the names of all the packages with their dependencies if you don't have access to a yum repo.

libgomp

e2fsprogs-devel

krb5-devel

glibc-headers

glibc-devel

zlib-devel

gcc

kernel-devel

openssl-devel

 

Compiling and installing the iSCSI target software

 

1. Extract the source from the tar file.

tar zxvf iscsitarget-0.4.15.tar.gz

2. Change into the new directory.


 

 

cd iscsitarget-0.4.15

3. Make the binaries to install.

make

Once this has finished you should see something like this, however your mileage may vary.

(Note: Output below is truncated)

make[1]: Leaving directory `/root/iscsitarget-0.4.15/usr'

make -C /lib/modules/2.6.18-8.el5/build SUBDIRS=/root/iscsitarget-0.4.15/kernel modules

make[1]: Entering directory `/usr/src/kernels/2.6.18-8.el5-i686'

CC [M] /root/iscsitarget-0.4.15/kernel/tio.o

CC [M] /root/iscsitarget-0.4.15/kernel/iscsi.o

CC [M] /root/iscsitarget-0.4.15/kernel/nthread.o

CC [M] /root/iscsitarget-0.4.15/kernel/wthread.o

CC [M] /root/iscsitarget-0.4.15/kernel/config.o

CC [M] /root/iscsitarget-0.4.15/kernel/digest.o

CC [M] /root/iscsitarget-0.4.15/kernel/conn.o

CC [M] /root/iscsitarget-0.4.15/kernel/session.o

CC [M] /root/iscsitarget-0.4.15/kernel/target.o

CC [M] /root/iscsitarget-0.4.15/kernel/volume.o

CC [M] /root/iscsitarget-0.4.15/kernel/iotype.o

CC [M] /root/iscsitarget-0.4.15/kernel/file-io.o

CC [M] /root/iscsitarget-0.4.15/kernel/null-io.o

CC [M] /root/iscsitarget-0.4.15/kernel/target_disk.o

CC [M] /root/iscsitarget-0.4.15/kernel/event.o

CC [M] /root/iscsitarget-0.4.15/kernel/param.o

CC [M] /root/iscsitarget-0.4.15/kernel/block-io.o

LD [M] /root/iscsitarget-0.4.15/kernel/iscsi_trgt.o

Building modules, stage 2.

MODPOST

CC /root/iscsitarget-0.4.15/kernel/iscsi_trgt.mod.o

LD [M] /root/iscsitarget-0.4.15/kernel/iscsi_trgt.ko

make[1]: Leaving directory `/usr/src/kernels/2.6.18-8.el5-i686'

4. Now to install the software.

make install


 

 

5. The install is now finished and should look something like this; again your mileage may vary.

install: creating directory `/lib/modules/2.6.18-8.el5/kernel/iscsi'

`kernel/iscsi_trgt.ko' -> `/lib/modules/2.6.18-8.el5/kernel/iscsi/iscsi_trgt.ko'

depmod -aq

`usr/ietd' -> `/usr/sbin/ietd'

`usr/ietadm' -> `/usr/sbin/ietadm'

`etc/initd/initd.redhat' -> `/etc/init.d/iscsi-target'

`etc/ietd.conf' -> `/etc/ietd.conf'

`etc/initiators.allow' -> `/etc/initiators.allow'

`etc/initiators.deny' -> `/etc/initiators.deny'

`doc/manpages/ietadm.8' -> `/usr/share/man/man8/ietadm.8'

`doc/manpages/ietd.8' -> `/usr/share/man/man8/ietd.8'

`doc/manpages/ietd.conf.5' -> `/usr/share/man/man5/ietd.conf.5'

install: creating directory `/usr/share/doc/iscsitarget'

`ChangeLog' -> `/usr/share/doc/iscsitarget/ChangeLog'

`COPYING' -> `/usr/share/doc/iscsitarget/COPYING'

`README' -> `/usr/share/doc/iscsitarget/README'

`README.vmware' -> `/usr/share/doc/iscsitarget/README.vmware'

 

Setting up the iSCSI target

1. First we need to edit the config. Example below is using vi but you can use any text editor that you are familiar with.

vi /etc/ietd.conf

2. Here is an example of a sample config to setup a raw device to be shared over iSCSI. T he ietd.conf file has more in depth info.

Sample Config:

Target iqn.2001-04.com.example:storage.disk2.sys1.xyz

Lun 0 Path=/dev/sdb,Type=fileio

Alias iDISK0


 

 

Starting/Automating the iscsi-target service on startup

 

1. First we will add the service to chkconfig.

chkconfig --add iscsi-target

2. Now we must turn the service on.

chkconfig iscsi-target on

3. Now to verify the changes took effect.

chkconfig --list iscsi-target

It should output something like this.

iscsi-target 0:off 1:off 2:on 3:on 4:on 5:on 6:off

4. Now the service can be started like any other Red Hat service.

service iscsi-target start

Now to verify the service started.

service iscsi-target status

The response should look something like this.

ietd (pid 14219) is running...

5. Now you are done. Once you have a iSCSI target connected you can view sessions.

cat /proc/net/iet/session

The response should look something like this as mileage will vary of course.

tid:1 name:iqn.2001-04.com.example:storage.disk2.sys1.xyz

sid:281474980708864 initiator:iqn.2005-03.com.redhat:01.4fb1df5ebfc1

cid:0 ip:192.168.1.200 state:active hd:none dd:none

 

To setup an iSCSI initiator look at the fallowing Red Hat article

http://kbase.redhat.com/faq/FAQ_103_10720.shtm