Mount and unmount FireWire drives via shell script

Jul 12, '07 07:30:00AM

Contributed by: Anonymous

I run a couple of different backups to FireWire drives during the night, but I don't want to see the FireWire drives during the day, since they clutter my desktop and slow down Open/Save dialogs. So I created the following two scripts to automatically mount and unmount all FireWire drives, then scheduled them to run at the right times: The mount script, which I named mntfw:

#!/bin/bash
system_profiler SPFireWireDataType | grep "BSD Name: disk.$" | \
sed "s/^.*: //" | (while read i; do /usr/sbin/diskutil mountDisk $i; done)
The unmount script, which I named nofw:
#!/bin/bash
system_profiler SPFireWireDataType | grep "BSD Name: disk.$" | \
sed "s/^.*: //" | (while read i; do /usr/sbin/diskutil unmountDisk $i; done)
Save these somewhere (make sure to use Unix line endings), then mark them as executable with chmod a+x mntfw nofw, and you can easily run them from the Terminal.

[robg adds: These worked as described when I tested them.]

Comments (9)


Mac OS X Hints
http://hints.macworld.com/article.php?story=20070712062603762