Automator's workflow to eject all ZFS disks

已查看 58 次
跳至第一个未读帖子

Gian M

未读,
2013年10月20日 07:36:592013/10/20
收件人 zfs-...@googlegroups.com
Hello, I joined just to share a piece of code I did on automator. I have one partition in my mac which uses ZFS and two external HDs which also use ZFS.

As you may be aware, to use USB devices such as external disks, we must eject everything manually with the console. Well, that's really annoying to do in a daily basis.

Plainly ejecting the device and connecting again will result in a kernel panic.

So, I made this crazy code here you can insert in a "Run AppleScript" step inside Automator. It will eject all ZFS disks at once (including the local partition).

on run {input, parameters}

do shell script "sudo -S sh -c 'zpool list | cut -d\" \" -f1 | grep -v NAME | xargs zpool export -f'" with administrator privileges

do shell script "sudo diskutil list | grep ZFS | awk -F ' ' '{print $3}' | while read a; do sudo diskutil info $a | grep 'Device Node' | awk -F ' ' '{print $3}' | xargs diskutil eject; done" with administrator privileges

return input

end run


Try it and enjoy!


I am using Snow Leopard 10.6.8. I tried in Mountain Lion 10.8.5, but it was not executing the last step properly because I forgot to iterate several disks. I didn't test after I fixed.


Cheers!


Gian

Jason Belec

未读,
2013年10月20日 08:09:342013/10/20
收件人 zfs-...@googlegroups.com
Great script. BUT, we really don't encourage the use of USB disks for numerous reasons. Search the wiki and the forum, especially for USB heartbreak stories (other forums as well). That said if your comfortable with the known risks when used with ZFS your good to go. 


--
Jason Belec
Sent from my iPad
--
 
---
You received this message because you are subscribed to the Google Groups "zfs-macos" group.
To unsubscribe from this group and stop receiving emails from it, send an email to zfs-macos+...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
回复全部
回复作者
转发
0 个新帖子