I've made applescripts to both mount and unmount my drive.
Regular HDD in my optical bay. Macbook Pro (late 2006). OSX Lion
Drive spins down and stays that way unless you open disk utility, resume from sleep, or remount the drive. Spotlight doesn't cause the drive to spin up. Neither does trying to access any alias on the drive.
-If there's running processes open that prevent the drive from ejecting, the script opens Activity monitor and runs lsof in a Terminal window.
-You can then decide if the process should be killed.
-A dialog box asks for user confirmation to kill.
I run these from the applescript menu. You can enable it like this:
- Open AppleScript Editor.app (Applications -> Utilities).
- Open Preferences….
- Check "Show Script menu in menu bar".
Mount drive
on run
try
do shell script "diskutil mountDisk disk1"
on error
end try
end run
Unmount drive
on run
try
do shell script "hdiutil eject disk1"
on error
tell application "System Events"
set termOpen to count (processes whose name is "Terminal")
set amOpen to count (processes whose name is "Activity Monitor")
end tell
tell application "Terminal"
activate
set newTab to do script "lsof /Volumes/'HFS HD'"
end tell
tell application "Activity Monitor"
activate
end tell
delay 3
set question to display dialog "Kill running?" buttons {"Yes", "No"} default button 2
set answer to button returned of question
if answer is equal to "Yes" then
do shell script "lsof -P | grep '/Volumes/HFS HD' | awk '{print $2}' | xargs kill -9"
do shell script "hdiutil eject disk1"
end if
tell application "Activity Monitor"
if amOpen is 0 then
quit
end if
end tell
tell application "Terminal"
if termOpen is 0 then
quit
else
close (first window whose selected tab is newTab) saving no
end if
end tell
end try
end run
Works perfect for me, hopefully you also have success!