8

Is there a way to automatically unmount a specific volume (mounted from a .dmg/.sparseimage) if it has not been accessed for a specified period?

EDIT:

  1. This would be especially useful for password protected images which contain sensitive data.

  2. Since I got no complete answer to this, I have asked a similar but simpler question here.

1

The OS doens't allow that out of the box (neither for dmg nor real partitions).

What I would do is create a script that would listen to that mounted image and after x time idle, unmount it.

Applescript is a fairly simple way to get that working (or via an automator flow).

Some pointers:

(the tricky part is getting the disk image idle)

http://www.mactech.com/articles/mactech/Vol.20/20.07/FolderWatching/index.html

http://webcache.googleusercontent.com/search?q=cache:IjvM1V_MxroJ:macscripter.net/viewtopic.php%3Fid%3D39468+&cd=4&hl=en&ct=clnk&client=safari

Checking for folder/file changes using Automator?

How to run Applescript on Disk mount

Automatically launch a program or action when an external drive or disk is connected

I'll make an example later today, but the flow will be like this:

open script

drag mounted image disk to it

monitor this disk access (every x time, to save processor)

if last time accessed > idlelimit then     
    eject disk
    quit script

otherwise

keep checking
  • why the downvote? – jackJoe Feb 27 '13 at 9:29
  • Thanks, that sounds like it will do the trick. I have never used Applescript. Can you provide a code snippet or pointers on how to get started? – Himanshu P Feb 27 '13 at 9:31
  • (I dunno who downvoted. I don't know enough yet to upvote or downvote your answer) – Himanshu P Feb 27 '13 at 9:32
  • @HimanshuPokhariya I updated with some links that I found, to help you get started. – jackJoe Feb 27 '13 at 9:47
  • 2
    Thanks for doing the research on this, there is a lot of good stuff in your answer already. To make it really great and useful for a broader audience, would you be able to provide a sample script showing how to implement this in real life? – nohillside Feb 27 '13 at 10:05

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .