openSUSE:Hastor/Lio

Jump to: navigation, search

Preliminary Configuration

This just to document how we proceeded, it is not yet final.

# cat startup.sh 
#!/bin/bash
rm -fv /var/crash/target.fault
#
/etc/init.d/target start
# create backend device
tcm_node --block iblock_0/my_drbd01 /dev/drbd1
tcm_node --fileio fileio_0/fileio_test /root/testfile_fileio 1073741824
tcm_node --fileio fileio_0/drbd2 /dev/drbd2 1073741824

# setup iscsi target driver 
IQN=$(iscsi-name)
# lio_node --addlun `iscsi-name` 1 0 my_drbd_iscsi_port iblock_0/my_drbd01
lio_node --addlun $IQN 1 0 my_drbd_iscsi_port iblock_0/my_drbd01
# search for iqn... 
# IQN=$(lio_node --listendpoints | sed -n 's/.*\(iqn.*\)/\1/p')
# setup target port group:
lio_node --addnp $IQN 1 10.10.3.105:3260
# add acl for hastor2:
lio_node --addlunacl $IQN 1 iqn.1996-04.de.suse:01:2851f05789e5 0 0
# disable authentication:
lio_node --disableauth $IQN 1
# enable target:
lio_node --enabletpg $IQN 1 

INITIATOR="21:00:00:e0:8b:91:2e:53"

# FC target:
modprobe tcm_qla2xxx
# find local wwpn:
WWPN=$(systool -A port_name -c fc_host | sed -n 's/.*port_name.*= "0x\(.* \)"/\1/p' | \
sed ':a;s/\(..\)\(..\)\(..\)\(..\)\(..\)\(..\)\(..\)\(..\)/\1:\2:\3:\4:\5:\6:\7:\8/')
# configure local target:
mkdir -p /sys/kernel/config/target/qla2xxx/${WWPN}/tpgt_1/lun/lun_0
mkdir -p /sys/kernel/config/target/qla2xxx/${WWPN}/tpgt_1/lun/lun_1
# attach block device
#ln -s /sys/kernel/config/target/core/iblock_0/my_drbd01/ /sys/kernel/config/target/qla2xxx/${WWPN}/tpgt_1/lun/lun_0/tcm_qla2xxx_port
ln -s /sys/kernel/config/target/core/fileio_0/fileio_test/ /sys/kernel/config /target/qla2xxx/${WWPN}/tpgt_1/lun/lun_0/tcm_qla2xxx_port
ln -s /sys/kernel/config/target/core/fileio_0/drbd2/ /sys/kernel/config/target/qla2xxx/${WWPN}/tpgt_1/lun/lun_1/tcm_qla2xxx_port
#
mkdir -p /sys/kernel/config/target/qla2xxx/${WWPN}/tpgt_1/acls/${INITIATOR}/lun_0
ln -sf /sys/kernel/config/target/qla2xxx/${WWPN}/tpgt_1/lun/lun_0 /sys/kernel/config/target/qla2xxx/${WWPN}/tpgt_1/acls/${INITIATOR}/lun_0/lun_0
mkdir -p /sys/kernel/config/target/qla2xxx/${WWPN}/tpgt_1/acls/${INITIATOR}/lun_1
ln -sf /sys/kernel/config/target/qla2xxx/${WWPN}/tpgt_1/lun/lun_1 /sys/kernel/config/target/qla2xxx/${WWPN}/tpgt_1/acls/${INITIATOR}/lun_1/lun_1

# enable FC target:
echo 1 > /sys/kernel/config/target/qla2xxx/${WWPN}/tpgt_1/enable