Friday, June 19, 2009

iSCSI Storage Initiator / Target in a Linux Environment

I have decided to share a short technical experience that i had recently. so in my pursue of a way to build a Home Linux Storage System , and also have a Software iSCSI interface to connect to it , since my home setup of hardware wont suffer an HBA addition . i did some research around sofware iSCSI. and although it is CPU Intensive, this might assist those of you that have a need for external disks.

the concept was to have a central home storage , have only small disks on my lab computers that will just run the thin OS , and then mount the drives from a central server – to which i connected a 1000/100/10 Switch just for data.

so the lab was divided into two.

1. A Linux Server that owns Physical Drives and serves as an iSCSI Target.

2. A Linux Workstation that needs to mount an external iSCSI disk Initiator.


1. How To Build The Linux Storage Server :

Install CENTOS 5.1
- yum update ( to update the OS to the latest )
- yum install kernel-devel ( optional )
- open firewall ports
- rpm -ivh iscsitarget-0.4.15-4.el5.i386.rpm
- rpm -ivh iscsitarget-kmdl-2.6.18-128.1.10.el5-0.4.15-4.el5.i686.rpm
- mkdir /home/iSCSI
- dd if=/dev/zero of=/home/iSCSI/LUN0 bs=1M count=512    ( 512 is size of disk in MB)
- vi /etc/ietd.conf and add the following lines
      IncomingUser username password
      OutgoingUser username password
      Lun 0 Path=/home/iSCSI/LUN0,Type=fileio
      Alias mydisk
      InitialR2T Yes
      ImmediateData Yes
      MaxOutstandingR2T 8

- vi /etc/initiators.allow 
      add -> ALL ALL ( note : This is an access list )
- reboot ( to make new kernel appear and load the module )
- /etc/init.d/iscsi-target restart
- validate in tail -f /var/log/messages


2. How To Have The Initiator Mount The Drive On The Workstation :

( my workstation is also a centos in this case )

-  rpm -i iscsi-initiator-utils- ( this is the util )

- vi /etc/iscsi/iscsid.conf
    #enable the following :
        node.session.auth.username = username
        node.session.auth.password = password
        discovery.sendtargets.auth.username = username
        discovery.sendtargets.auth.password = password

- /etc/init.d/iscsi start
- iscsiadm -m discovery -t sendtargets -p <ip of server>
- /etc/init.d/iscsi restart
- tail -f /var/log/messages --> to find the device representation
- fdisk /dev/sdd --> if the disk is sdd ...
        n primary partition
        w write table
- mkfs.ext3 /dev/sdd1
- mkdir /mnt/iscsi
- mount /dev/sdd1 /mnt/iscsi
- chkconfig iscsi on --> to mount at boot time auto
- vi /etc/fstab
         add line -> /dev/sdd1 /mnt/iscsi ext3 _netdev 0 0

by the way , mounting an iSCSI using Windows Vista is also an easy task .. play with it :)


Anyway, Thats it.

Labels: , , , ,


    My Name is Barry Shteiman, im a devoted tech junkie, and this is my blog.
    E: barry.shteiman -at-
    Twitter : bshteiman

Tags & Categories

Mailing List & RSS

Stay Updated  
Add to Technorati Favorites