-
-
Save mattconnolly/e188fdb1049872ec428d to your computer and use it in GitHub Desktop.
#!/bin/bash -x | |
# based on: http://superuser.com/questions/386506/hosting-iscsi-on-smartos | |
GROUPNAME=iscsi-1 | |
TARGETNAME=iqn.2010-08.org.illumos:02:$GROUPNAME | |
LOCAL_ADDRESS=192.168.1.2 | |
svcadm enable stmf | |
svcadm enable -r svc:/network/iscsi/target:default | |
sbdadm create-lu /dev/zvol/rdsk/zones/iscsi-1 | |
GUID=$(sbdadm list-lu | tail -n 1 | cut -f1 -d' ') | |
stmfadm add-view $GUID | |
itadm create-tpg "$GROUPNAME" $LOCAL_ADDRESS | |
itadm create-target -t "$GROUPNAME" -n $TARGETNAME |
Hi matt.
Did you eventually solve the iscsi startup, as I have been struggling with this.
Regards tony
cat /opt/custom/share/svc/smartos_setup.sh
!/bin/bash
Simple Ad Hoc SmartOS Setup Service
set -o xtrace
. /lib/svc/share/smf_include.sh
cd /
PATH=/usr/sbin:/usr/bin:/opt/custom/bin:/opt/custom/sbin; export PATH
case "$1" in
'start')
#### Insert code to execute on startup here.
cp /opt/custom/init /etc/default/init
hostname "store" && hostname > /etc/nodename
rtc -z US/Eastern
GROUPNAME=store
TARGETNAME=iqn.2010-08.org.illumos:02:$GROUPNAME
LOCAL_ADDRESS=192.168.0.90
svcadm enable stmf
svcadm enable -r svc:/network/iscsi/target:default
sbdadm create-lu /dev/zvol/rdsk/zones/iscsi
GUID=$(sbdadm list-lu | tail -n 1 | cut -f1 -d' ')
stmfadm add-view $GUID
itadm create-tpg "$GROUPNAME" $LOCAL_ADDRESS
itadm create-target -t "$GROUPNAME" -n $TARGETNAME
;;
'stop')
### Insert code to execute on shutdown here.
;;
*)
echo "Usage: $0 { start | stop }"
exit $SMF_EXIT_ERR_FATAL
;;
esac
exit $SMF_EXIT_OK
I haven't yet found a way for this to run automatically on a system boot...