Site icon UnixArena

How to setup ISCSI initiator on Redhat Linux ?

Here we are going to see about adding ISCSI targets on redhat Linux.SAN environment is highly impossible for small companies due to it’s cost.As an alternative, ISCSI provides a SAN like environment using storage via IP concept. To use ISCSI  storage , you need a high speed LAN cards and cables to achieve the speed like fiber channel SAN network. ISCSI uses TCP/IP port 3260 by default for storage access. In Redhat linux, rc.sysinit attempts to mount the all the filesystem before network and iscsid services have started.To overcome this issue, you need to add “_netdev” option in fstab for ISCSI device filesystems.

Here i am using openfiler as ISCSI storage box.Once you provisioned the luns from openfiler ,then  you can add those targets in redhat Linux to see those iscsi LUNS.

ISCSI initiator driver configuration file : /etc/iscsi/iscsid.conf.

Here is the openfiler provisioned LUNS.











Now login to redhat Linux and add the targets to get the LUNS access.

1.Verify iscsi initiator packages are installed or not in the redhat Linux host where you want to access iscsi storage.

[root@mylinz ~]# uname -a
Linux mylinz 2.6.32-71.el6.x86_64 #1 SMP Wed Sep 1 01:33:01 EDT 2010 x86_64 x86_64 x86_64 GNU/Linux
[root@mylinz ~]# rpm -qv iscsi-initiator-utils*
package iscsi-initiator-utils* is not installed
[root@mylinz ~]# rpm -qv iscsi-initiator-utils.x86_64
package iscsi-initiator-utils.x86_64 is not installed
[root@mylinz ~]#


2.If its not installed,You can install the iscsi initiator package using yum.If don’t have yum repository configured on your server,you can install the package using “rpm -ivh iscsi-initiator-utils.x86_64” .  To configure yum,Please refer this article

[root@mylinz ~]# yum install iscsi-initiator-utils.x86_64
Loaded plugins: refresh-packagekit, rhnplugin
This system is not registered with RHN.
RHN support will be disabled.
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package iscsi-initiator-utils.x86_64 0:6.2.0.872-10.el6 set to be updated
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================
Package Arch Version Repository Size
================================================================================
Installing:
iscsi-initiator-utils x86_64 6.2.0.872-10.el6 local-installation 559 k

Transaction Summary
===============================================================================
Install 1 Package(s)
Upgrade 0 Package(s)

Total download size: 559 k
Installed size: 1.9 M
Is this ok [y/N]: y
Downloading Packages:
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : iscsi-initiator-utils-6.2.0.872-10.el6.x86_64 1/1

Installed:
iscsi-initiator-utils.x86_64 0:6.2.0.872-10.el6

Complete!
[root@mylinz ~]#


3.Make sure ISCSI service will start across the reboot.

[root@mylinz ~]# chkconfig iscsi on
[root@mylinz ~]# chkconfig |grep iscsi
iscsi 0:off 1:off 2:on 3:on 4:on 5:on 6:off
iscsid 0:off 1:off 2:off 3:on 4:on 5:on 6:off
[root@mylinz ~]#

4.Add the ISCSI storage target details. Here you need to provide the openfiler information.

[root@mylinz ~]# iscsiadm -m discovery -t sendtargets -p 192.168.10.10:3260
Starting iscsid: [ OK ]
192.168.10.10:3260,1 iqn.2006-01.com.openfiler:tsn.c27c73a506b2
[root@mylinz ~]#

5. View information about  the newly discovered target.

[root@mylinz ~]# iscsiadm -m node -T iqn.2006-01.com.openfiler:tsn.c27c73a506b2 -p 192.168.10.10:3260
# BEGIN RECORD 2.0-872
node.name = iqn.2006-01.com.openfiler:tsn.c27c73a506b2
node.tpgt = 1
node.startup = automatic
iface.hwaddress =
iface.ipaddress =
iface.iscsi_ifacename = default
iface.net_ifacename =
iface.transport_name = tcp
iface.initiatorname =
node.discovery_address = 192.168.10.10
node.discovery_port = 3260
node.discovery_type = send_targets
node.session.initial_cmdsn = 0
node.session.initial_login_retry_max = 8
node.session.xmit_thread_priority = -20
node.session.cmds_max = 128
node.session.queue_depth = 32
node.session.auth.authmethod = None
node.session.auth.username =
node.session.auth.password =
node.session.auth.username_in =
node.session.auth.password_in =
node.session.timeo.replacement_timeout = 120
node.session.err_timeo.abort_timeout = 15
node.session.err_timeo.lu_reset_timeout = 30
node.session.err_timeo.tgt_reset_timeout = 30
node.session.err_timeo.host_reset_timeout = 60
node.session.iscsi.FastAbort = Yes
node.session.iscsi.InitialR2T = No
node.session.iscsi.ImmediateData = Yes
node.session.iscsi.FirstBurstLength = 262144
node.session.iscsi.MaxBurstLength = 16776192
node.session.iscsi.DefaultTime2Retain = 0
node.session.iscsi.DefaultTime2Wait = 2
node.session.iscsi.MaxConnections = 1
node.session.iscsi.MaxOutstandingR2T = 1
node.session.iscsi.ERL = 0
node.conn[0].address = 192.168.10.10
node.conn[0].port = 3260
node.conn[0].startup = manual
node.conn[0].tcp.window_size = 524288
node.conn[0].tcp.type_of_service = 0
node.conn[0].timeo.logout_timeout = 15
node.conn[0].timeo.login_timeout = 15
node.conn[0].timeo.auth_timeout = 45
node.conn[0].timeo.noop_out_interval = 5
node.conn[0].timeo.noop_out_timeout = 5
node.conn[0].iscsi.MaxXmitDataSegmentLength = 0
node.conn[0].iscsi.MaxRecvDataSegmentLength = 262144
node.conn[0].iscsi.HeaderDigest = None
node.conn[0].iscsi.IFMarker = No
node.conn[0].iscsi.OFMarker = No
# END RECORD
[root@mylinz ~]#

6. Login to ISCSI target to access the LUNS .

[root@mylinz ~]# iscsiadm -m node -T iqn.2006-01.com.openfiler:tsn.c27c73a506b2 -p 192.168.10.10:3260 -l
Logging in to [iface: default, target: iqn.2006-01.com.openfiler:tsn.c27c73a506b2, portal: 192.168.10.10,3260]
Login to [iface: default, target: iqn.2006-01.com.openfiler:tsn.c27c73a506b2, portal: 192.168.10.10,3260] successful.
[root@mylinz ~]#

7.Check the new iscsi disks using the “fdisk -l”command.The below mentioned disks are visible in fdisk command from ISCSI storage.

Disk /dev/sdh: 637 MB, 637534208 bytes
Disk /dev/sdi: 234 MB, 234881024 bytes

8.Create a filesystem on the iscsi device or use it under LVM for data storage.

[root@mylinz ~]# mkfs.ext4 /dev/sdh
mke2fs 1.41.12 (17-May-2010)
/dev/sdh is entire device, not just one partition!
Proceed anyway? (y,n) y
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
38960 inodes, 155648 blocks
7782 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=159383552
5 block groups
32768 blocks per group, 32768 fragments per group
7792 inodes per group
Superblock backups stored on blocks:
32768, 98304

Writing inode tables: done
Creating journal (4096 blocks): done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 38 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
You have new mail in /var/spool/mail/root
[root@mylinz ~]# mount -t ext4 /dev/sdh /mnt
[root@mylinz ~]# df -h /mnt
Filesystem Size Used Avail Use% Mounted on
/dev/sdh 599M 17M 552M 3% /mnt
[root@mylinz ~]#

9.If you want to logout from the iscsi session, then use the below command.

[root@mylinz ~]# iscsiadm -m node -T iqn.2006-01.com.openfiler:tsn.c27c73a506b2 -p 192.168.10.10:3260 -u

10.To remove the target completely from this host,use the below command after logout from the session.You need to restart the iscsi service to see the changes.

[root@mylinz ~]# iscsiadm -m node -T iqn.2006-01.com.openfiler:tsn.c27c73a506b2 -p 192.168.10.10:3260 -o delete
[root@mylinz ~]# service iscsi restart

Hope this article will help you to add/remove iscsi targets in redhat Linux.You can also view that how to add iscsi target in solaris.

 Thank you for visiting UnixArena.

Exit mobile version