Created
May 19, 2014 12:10
-
-
Save mattconnolly/e188fdb1049872ec428d to your computer and use it in GitHub Desktop.
setup iscsi share on smartos
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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