iSCSI initiator configuration in RedHat Enterprise Linux 5

February 22, 2011 — 12 Comments

The following post will discuss about iSCSI initiator configuration in RedHat Enterprise Linux 5, this method is also applicable to all RHEL5 derivatives. The iSCSI LUNs will be provided by an HP P4000 array.

First of all we need to get and install the iscsi-initiator-utils RPM package, you can use yum to get and install the package from any supported repository for CentOS or RHEL. You can also download the package from RedHat Network if you have a valid RHN account and your system doesn’t have internet connection.

[root@rhel5 ~]# rpm -ivh /tmp/iscsi-initiator-utils-6.2.0.871-0.16.el5.x86_64.rpm
Preparing...                ########################################### [100%]
   1:iscsi-initiator-utils  ########################################### [100%]
[root@rhel5 ~]#
[root@rhel5 ~]#rpm -qa | grep iscsi
iscsi-initiator-utils-6.2.0.871-0.16.el5
[root@rhel5 ~]# rpm -qi iscsi-initiator-utils-6.2.0.871-0.16.el5
Name        : iscsi-initiator-utils        Relocations: (not relocatable)
Version     : 6.2.0.871                         Vendor: Red Hat, Inc.
Release     : 0.16.el5                      Build Date: Tue 09 Mar 2010 09:16:29 PM CET
Install Date: Wed 16 Feb 2011 11:34:03 AM CET      Build Host: x86-005.build.bos.redhat.com
Group       : System Environment/Daemons    Source RPM: iscsi-initiator-utils-6.2.0.871-0.16.el5.src.rpm
Size        : 1960412                          License: GPL
Signature   : DSA/SHA1, Wed 10 Mar 2010 04:26:37 PM CET, Key ID 5326810137017186
Packager    : Red Hat, Inc. <http://bugzilla.redhat.com/bugzilla>
URL         : http://www.open-iscsi.org
Summary     : iSCSI daemon and utility programs
Description :
The iscsi package provides the server daemon for the iSCSI protocol,
as well as the utility programs used to manage it. iSCSI is a protocol
for distributed disk access using SCSI commands sent over Internet
Protocol networks.
[root@rhel5 ~]#

Next we are going to configure the initiator. The iSCSI initiator is composed by two services, iscsi and iscsid, enable them to start at system startup using chkconfig.

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

Once iSCSI is configured start the service.

[root@rhel5 ~]# service iscsi start
iscsid is stopped
Starting iSCSI daemon:                                     [  OK  ]
                                                           [  OK  ]
Setting up iSCSI targets: iscsiadm: No records found!
                                                           [  OK  ]
[root@rhel5 ~]#
[root@rhel5 ~]# service iscsi status
iscsid (pid  14170) is running...
[root@rhel5 ~]#

From the P4000 CMC we need to add the server to the management group configuration like we would do with any other server.

The server iqn can be found in the file /etc/iscsi/initiatorname.iscsi.

[root@cl-node1 ~]# cat /etc/iscsi/initiatorname.iscsi
InitiatorName=iqn.1994-05.com.redhat:2551bf29b48
[root@cl-node1 ~]#

Create any iSCSI volumes you need in the P4000 arrays and assign them to the RedHat system. Then to discover the presented LUNs, from the Linux server run the iscsiadm command.

[root@rhel5 ~]# iscsiadm -m discovery -t sendtargets -p 192.168.126.60
192.168.126.60:3260,1 iqn.2003-10.com.lefthandnetworks:mlab:62:lv-rhel01
[root@rhel5 ~]#

Restart the iSCSI initiator to make the new block device available to the operative system.

[root@rhel5 ~]# service iscsi restart
Stopping iSCSI daemon:
iscsid dead but pid file exists                            [  OK  ]
Starting iSCSI daemon:                                     [  OK  ]
                                                           [  OK  ]
Setting up iSCSI targets: Logging in to [iface: default, target: iqn.2003-10.com.lefthandnetworks:mlab:62:lv-rhel01, portal: 192.168.126.60,3260]
Login to [iface: default, target: iqn.2003-10.com.lefthandnetworks:mlab:62:lv-rhel01, portal: 192.168.126.60,3260]: successful
                                                           [  OK  ]
[root@rhel5 ~]#

Then check that the new disk is available, I used lsscsi but fdisk -l will do the trick too.

[root@rhel5 ~]# lsscsi
[0:0:0:0]    disk    VMware,  VMware Virtual S 1.0   /dev/sda
[2:0:0:0]    disk    LEFTHAND iSCSIDisk        9000  /dev/sdb
[root@rhel5 ~]#
[root@rhel5 ~]# fdisk -l /dev/sdb 

Disk /dev/sdb: 156.7 GB, 156766306304 bytes
255 heads, 63 sectors/track, 19059 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Disk /dev/sdb doesn't contain a valid partition table
[root@rhel5 ~]#

At this point the iSCSI configuration is done, the new LUNs will be available through a system reboot as long as the iSCSI service is enabled.

Juanma.

About these ads

12 responses to iSCSI initiator configuration in RedHat Enterprise Linux 5

  1. 

    Remember to format your /dev/sdb i.e mkfs.ext3 /dev/sdb1 as a partition.
    Then mount your partition i.e /dev/sdb1 using /etc/fstab on your server and your desired directory as destination.

  2. 

    Is there any editing of /etc/iscsi/iscsid.conf needed?

  3. 

    How do you do the last step: Then mount your partition i.e /dev/sdb1 using /etc/fstab on your server and your desired directory as destination?

  4. 

    Also how to Remember to format your /dev/sdb i.e mkfs.ext3 /dev/sdb1 as a partition

  5. 
    Jeevan Sapkota July 25, 2012 at 13:07

    For Formatting:

    #fdisk /dev/sdb
    Command (m for help): n
    Partition type:
    p primary (0 primary, 0 extended, 4 free)
    e extended
    Select (default p): p
    Partition number (1-4, default 1): 1
    First sector (2048-1048575, default 2048): (Enter Key)
    Using default value 2048
    Last sector, +sectors or +size{K,M,G} (2048-1048575, default 1048575): (Enter Key)
    Using default value 1048575

    Command (m for help): w
    The partition table has been altered!

    Calling ioctl() to re-read partition table.
    Syncing disks.

    #mkfs -t ext3 /dev/sdb1

    You can use ext4 as well. Just replace all ext3 with ext4.

    No editing in the /etc/iscsi/iscsid.conf is needed

    In etc/fstab,
    add the following line:

    /dev/sdb1 /full-path-of-mount-directory ext3 _netdev 0 0

    or

    #echo “/dev/sdb1 /full-path-of-mount-directory ext3 _netdev 0 0″ >> /etc/fstab

  6. 

    Hello there! I know this is kinda off topic however , I’d figured I’d ask.

    Would you be interested in trading links or maybe guest authoring a blog article or vice-versa?
    My blog covers a lot of the same topics as yours and I think we could greatly benefit from each other.
    If you’re interested feel free to send me an email. I look forward to hearing from you!
    Superb blog by the way!

  7. 

    This site was… how do I say it? Relevant!! Finally I’ve
    found something which helped me. Cheers!

  8. 

    My brother suggested I might like this website.

    He was totally right. This post actually made my day.
    You cann’t imagine just how much time I had spent for this information! Thanks!

  9. 

    I’ve been exploring for a little bit for any high-quality articles
    or blog posts on this sort of house . Exploring in Yahoo I at last stumbled upon this web site.
    Studying this information So i’m satisfied to convey that I
    have an incredibly excellent uncanny feeling I found out exactly what I needed.

    I such a lot undoubtedly will make certain to do not put
    out of your mind this site and provides it a look regularly.

Trackbacks and Pingbacks:

  1. iSCSI initiator configuration in RedHat Enterprise Linux 5 | unixsecure secondary - March 7, 2011

    [...] post: iSCSI initiator configuration in RedHat Enterprise Linux 5 This entry was posted in Uncategorized, X86 and tagged build, build-date, build-host, cet, group, [...]

  2. DISTRO DESKTOP Linux Terbaik - April 13, 2012

    [...] var emooo = function(kodeemo){ var ads_id = document.getElementById("comment"); return ads_id.value = ads_id.value.substring(0, ads_id.selectionStart) + ads_id.value.substring(ads_id.selectionEnd, ads_id.value.length) + " " + kodeemo ; }; var toggle = function(){ document.getElementById("commentemotitle").innerHTML = document.getElementById("commentemo").style.display == "" ? "":""; document.getElementById("commentemo").style.display = document.getElementById("commentemo").style.display == "" ? "none":""; }; var _gaq = _gaq || []; _gaq.push(['_setAccount', '38982897']); _gaq.push(['_trackPageview']); _gaq.push(['_trackPageLoadTime']); (function() { var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; ga.src = ('https:' == document.location.protocol ? 'https://ssl&#039; : 'http://www&#039;) + '.google-analytics.com/ga.js'; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); })(); 10 Distro GNU/Linux terbaik 201114 jenis Distro Linux terbaikArtikel : 10 Distro LINUX Terbaik 2011 versi TechRadar (5) – Distro Terbaik untuk DesktopDesktop LinuxThe top 20 strongholds for desktop Linux6 Desktop Environment paling ngetop6 Desktop Environment paling ngetopLinux Mint 11 Review – Linux Distro ReviewsiSCSI initiator configuration in RedHat Enterprise Linux 5 [...]

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s