1

I'd like to auto mount my dmg file which represent disk image with single HFS+ partition upon every boot. is it possible through autofs ? do I have to set the location of the dmg file in any configuration file (/etc/...)

thanks

1 Answer 1

1

You can simply add the .dmg file to your Login Items in: System Preferences > Users & Groups > (you) > Login Items

The .dmg file will then automatically be mounted when you login.


Update to address comment: "Is there any API to add item to login items programmatically?"

One programatic way I know of, it can be done with AppleScript:

Example AppleScript code:

tell application "System Events" to ¬ make new login item with properties ¬ {name:"Mount DMG", path:"/path/to/filename.dmg", hidden:true} 
  • Change "Mount DMG" and "/path/to/filename.dmg" as appropriate.

It can also be done from Terminal using, using the osascript command, with the same AppleScript command:

osascript -e 'tell application "System Events" to make new login item with properties {name:"Mount DMG", path:"/path/to/filename.dmg", hidden:true}' 
  • Change "Mount DMG" and "/path/to/filename.dmg" as appropriate.
2
  • Hi and thanks for you reply, is there any API to add item to login items pro grammatically ? Commented Mar 4, 2018 at 22:21
  • @Zohar81, I've updated my answer to address your comment. Commented Mar 4, 2018 at 23:10

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.