Debian iSCSI Initiator and Target


We are going to show you how to configure iSCSI between two Debian servers. You can connect multiple Debian iSCSI Initiators and share the same Target LUN.

Setting up iSCSI Target

On the target server that will host the LUN’s you need to install iSCSI Target software

apt-get install iscsitarget iscsitarget-dkms

Than set ISCSITARGET_ENABLE to true in /etc/default/iscsitarget

vi /etc/default/iscsitarget
ISCSITARGET_ENABLE=true

We can use unused logical volumes, image files, hard drives, hard drive partitions or RAID devices for the storage.

We are going to use the /dev/sdb hard drive partition. For that you need to edit /etc/iet/ietd.conf with this configuration. The target name must be a globally unique name, the iSCSI standard defines the “iSCSI Qualified Name” as follows: iqn.yyyy-mm.<reversed domain name>[:identifier]

vi /etc/iet/ietd.conf
Target iqn.2012-09.com.yourdomain:datastore.lun1
        IncomingUser myuser mypassword
        OutgoingUser
        #make sure the partition isn't mounted :
        Lun 0 Path=/dev/sdb,Type=fileio
        Alias LUN1
        #MaxConnections 6

Now we need to allow our initiator server to access the lun and start the Target server.

vi /etc/iet/initiators.allow
iqn.2012-09.com.yourdomain:datastore.lun1 <Initiator_IP>
/etc/init.d/iscsitarget start

Setting up iSCSI Initiator

On the Initiator server we need to install open-iscsi and set it to start automatically

apt-get install open-iscsi
vi /etc/iscsi/iscsid.conf
node.startup = automatic
etc/init.d/open-iscsi restart

Now we need to check what the target server is offering and add authentication to connect to our LUN

iscsiadm -m discovery -t st -p <Target_Server_IP>
Output:
<Target_Server_IP>:3260,1 iqn.2012-09.com.mydomain:datastore.lun1
iscsiadm -m node
Output:
<Target_Server_IP>:3260,1 iqn.2012-09.com.mydomain:datastore.lun1

The settings are stored in the file /etc/iscsi/nodes/iqn.2012-09.com.mydomain:datastore.lun1/<Target_Server_IP>,3260,1/default. We need to add the authentication with this commands

iscsiadm -m node --targetname "iqn.2012-09.com.mydomain:datastore.lun1" --portal "<Target_Server_IP>:3260" --op=update --name node.session.auth.authmethod --value=CHAP
iscsiadm -m node --targetname "iqn.2012-09.com.mydomain:datastore.lun1" --portal "<Target_Server_IP>:3260" --op=update --name node.session.auth.username --value=myuser
iscsiadm -m node --targetname "iqn.2012-09.com.mydomain:datastore.lun1" --portal "<Target_Server_IP>:3260" --op=update --name node.session.auth.password --value=mypasword

Now you can login or restart the iSCSI Initiator

iscsiadm -m node --targetname "iqn.2012-09.com.mydomain:datastore.lun1" --portal "<Target_Server_IP>:3260" --login
/etc/init.d/open-iscsi restart

That’s it! You can see the disk on your Initiator server

fdisk -l

Create partitions and mount it from /etc/fstab

Debianhttp://www.debian.org/
iSCSI Enterprise Targethttp://iscsitarget.sourceforge.net/
Open-iSCSIhttp://www.open-iscsi.org/



Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments

Advertisement