Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Test tgtd iSER connection via pib (tested in Fedora 21)
#!/bin/sh
IB_ADDR=172.24.100.1
TARGET_IQN=iqn.2015-05.com.example:test
if [ $EUID -ne 0 ]; then
sudo "$0" "$@"
exit $?
fi
set -e
echo Activating pib...
systemctl start rdma
modprobe pib num_hca=1
systemctl start opensm
ip a add $IB_ADDR dev ib0
echo Activating tgtd...
modprobe ib_iser
systemctl restart tgtd
echo Creating iSER target...
dd if=/dev/zero of=/tmp/diskimg bs=1M count=256
tgtadm --lld iser -m target -o new --tid 1 --targetname $TARGET_IQN
tgtadm --lld iser -m logicalunit -o new --tid 1 --lun 1 -b /tmp/diskimg
tgtadm --lld iser --mode target --op bind --tid 1 -I ALL
echo Discovering iSER targets...
sleep 3
iscsiadm -m discovery --type sendtargets -p $IB_ADDR -I iser
echo Logging into iSER portal...
iscsiadm -m node --login -I iser -p $IB_ADDR -T $TARGET_IQN
echo Logging out of iSER portal...
iscsiadm -m node -I iser -p $IB_ADDR -T $TARGET_IQN --logout
iscsiadm -m node -I iser -p $IB_ADDR -T $TARGET_IQN -o delete
echo Deleting iSER target...
tgtadm --lld iser --mode target -o delete --tid 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment