2012-10-05 22:53, Edward Ned Harvey
(opensolarisisdeadlongliveopensolaris) wrote:
http://nedharvey.com/blog/?p=105
Nice writeup, thanks. Perhaps you could also post/link it on OI wiki
so the community can find it easier?
A few comments:
1) For readability I'd use "...| awk '{print $1}'" instead of sed:
- for GUID in `sudo sbdadm list-lu | grep rdsk | sed 's/ .*//'`
+ for GUID in `sudo sbdadm list-lu | grep rdsk | awk '{print $1}'`
On one hand, different implementations of sed might parse regexps
differently, on the other - column order might change and changing
a number in awk would be more straightforward.
2) Here you can just redirect stdio from /dev/null:
- sudo format -e # Make a note of the new device names. And hit Ctrl-C.
+ sudo format -e < /dev/null
3) In iscsi-pool-ctrl.sh it is more readable to replace the
'if "$1"...elif..else' clause with 'case "$1" in ... esac'
That is also easier to expand if needed; for example, to alias
'import|start)' and 'export|stop)' for more standard method
naming.
3.1) Also you should probably do "zpool import -o cachefile ..."
or plain "zpool import -R / ..." to set a particular cachefile
or use none, to avoid auto-import upon boot via standard file
/etc/zfs/zpool.cache (which can break your filesystem/local
service).
Also note that use of the altroot (-R) option disables the
cachefile by default, so you can use it as a shortcut.
3.2) The exit errors should be aligned with SMF status codes, so
you should include /lib/svc/share/smf_include.sh and return
one of these:
SMF_EXIT_OK=0
SMF_EXIT_ERR_FATAL=95
SMF_EXIT_ERR_CONFIG=96
SMF_EXIT_MON_DEGRADE=97
SMF_EXIT_MON_OFFLINE=98
SMF_EXIT_ERR_NOSMF=99
SMF_EXIT_ERR_PERM=100
(You can validate inclusion of that file, so if it fails, you
can define these values yourself for the script, i.e. to use
it as an initscript on a system without SMF).
3.3) To catch "device busy" errors you can retry failed zpool
export runs with "zpool export -f" which tries a bit harder.
Otherwise, quite LGTM :)
HTH,
//Jim Klimov
_______________________________________________
zfs-discuss mailing list
zfs-discuss@opensolaris.org
http://mail.opensolaris.org/mailman/listinfo/zfs-discuss