- Registriert
- 25.01.10
- Beiträge
- 1.386
Hi,
da ich meine NAS (endlich!
) auf ZFS umgestellt habe, wollte ich zum Transfer von Dateien von den Macs zur NAS ebenfalls ZFS-Drives benutzen, v.a. um mehr (bzw. überhaupt) Erfahrung im Umgang mit ZFS zu bekommen.
Also prompt maczfs installiert und nicht lange gebraucht, um über issue 3 zu stolpern.
Dummerweise findet kein zpool export statt, wenn ein ZFS-FS unmounted wird und da der failmode per default panic zu sein scheint, bekommt der Kernel halt Panik, wenn man das USB-LW abzieht und der Pool noch verfügbar sein sollte.
Meine Lösung ist folgende:
- Ein LaunchAgent der /Volumes überwacht und bei Änderungen ein Shell Script triggert
- Besagtes Shell Script. Es überprüft, ob die mit zfs list -H -o mountpoint ausgegebenen Verzeichnisse existieren und falls nicht, dann führt es ein zpool export -f aus, gefolgt von einer visuellen MSG.
Hier ist die launchd plist:
Und hier das Shell Script:
Bisher funktioniert das so für mich zuverlässig (allerdings auch erst 1d im Einsatz).
Hat noch jmd. Erfahrung mit ZFS auf OSX und mir Hinweise für andere Problematiken, die auftreten könnten oder Ideen/Vorschläge, wie man es besser machen könnte?
Thx.
da ich meine NAS (endlich!

Also prompt maczfs installiert und nicht lange gebraucht, um über issue 3 zu stolpern.
Dummerweise findet kein zpool export statt, wenn ein ZFS-FS unmounted wird und da der failmode per default panic zu sein scheint, bekommt der Kernel halt Panik, wenn man das USB-LW abzieht und der Pool noch verfügbar sein sollte.
Meine Lösung ist folgende:
- Ein LaunchAgent der /Volumes überwacht und bei Änderungen ein Shell Script triggert
- Besagtes Shell Script. Es überprüft, ob die mit zfs list -H -o mountpoint ausgegebenen Verzeichnisse existieren und falls nicht, dann führt es ein zpool export -f aus, gefolgt von einer visuellen MSG.
Hier ist die launchd plist:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" \
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<dict>
<key>Label</key>
<string>de.fyysh.zpool-exporter</string>
<key>Program</key>
<string>/Library/Scripts/LaunchAgent Scripts/zpool-exporter/zpool-exporter.sh</string>
<key>ProgramArguments</key>
<array>
<string>zpool-exporter.sh</string>
</array>
<key>WatchPaths</key>
<array>
<string>/Volumes</string>
</array>
</dict>
</plist>
Und hier das Shell Script:
Code:
#!/bin/bash
# get the ZFS mountpoints
ZFS_MOUNTPOINTS="$(zfs list -o mountpoint -H)"
# if ZFS_MOUNTPOINTS is empty, then there's no zpool active and we can exit
if [ -z "$ZFS_MOUNTPOINTS" ]; then exit 0; fi
# if ZPOOL_COUNT>0, then we need to check which of the zpools are still mounted and where
# if no dir exists in zfs mountpoint, the zpool must be exported
# set IFS to \n just in case a zpool name has spaces
IFS=$'\n'
for aPool in $(zfs list -o mountpoint -H); do # loop with every mounted zfs volume
if [ ! -d "$aPool" ]; then # if the mountpoint listed in zfs list does not exist...
if zpool export -f "$(basename $aPool)"; then # ...export the zpool
EXP_SYSLOG_MSG="Successfully exported zpool $(basename "$aPool")"
EXP_USER_MSG="Successfully exported ZFS Storage Pool\\n'$(basename "$aPool")'"
EXP_USER_MSG_TITLE="ZFS Storage Pool Export"
GROWL_STICKY_OPT=""
OSAMSG_ICON="note"
else
EXP_SYSLOG_MSG="Failed to export zpool $(basename "$aPool")"
EXP_USER_MSG="Failed to exported ZFS Storage Pool\\n'$(basename "$aPool")'"
EXP_USER_MSG_TITLE="ERROR! ZFS Storage Pool Export"
GROWL_STICKY_OPT="--sticky"
OSAMSG_ICON="caution"
fi
logger -is -t $(basename "$0") "$EXP_SYSLOG_MSG" # write to syslog
# list remaining zfs volumes
test $(zpool list -H | awk 'END{print NR}') -gt 0 \
&& EXP_USER_MSG="$EXP_USER_MSG\\n\\nAvailable ZFS volumes:\\n$(zfs list -o mountpoint -H)" \
|| EXP_USER_MSG="$EXP_USER_MSG\\n\\nNo more ZFS volumes available"
# notify user
if [ -f /usr/local/bin/growlnotify ]; then # if growlnotify exists...
printf "$EXP_USER_MSG" | /usr/local/bin/growlnotify -t "$EXP_USER_MSG_TITLE" -a Finder $GROWL_STICKY_OPT # ...use it...
else # ...else show dialog with osascript & finder
osascript -e "tell app \"finder\"" \
-e "activate" \
-e "display dialog \"$EXP_USER_MSG\" buttons {\"OK\"} default button 1 with icon $OSAMSG_ICON with title \"$EXP_USER_MSG_TITLE\"" \
-e "end"
fi
fi
done
Bisher funktioniert das so für mich zuverlässig (allerdings auch erst 1d im Einsatz).
Hat noch jmd. Erfahrung mit ZFS auf OSX und mir Hinweise für andere Problematiken, die auftreten könnten oder Ideen/Vorschläge, wie man es besser machen könnte?
Thx.