I have a question about "hdiutil attach"

I've "created" (ctrl+c/ctrl+v) one bash script to execute some .app automatically.

First im mounting shared folder:

mount_smbfs -o nobrowse //SERVER/share "/Users/user_name/APPNAME/18"

and attaching with the help of "hdiutil" the .dmg file
(you must attach .dmg in order to install this app :) )

hdiutil attach -nobrowse /Users/user_name/APPNAME/18/appname.dmg

so far so good. But! if im going to deploy it on multiple end-devices, i suppose its going to cause some issues.

So that's my question: Is it possible to attach the same file on multiple Computers at the same time? And if so, is it possible to execute this file from them?

Thanks for yout help!


Is it possible to attach the same file on multiple Computers at the same time?

This is possible if -- AND ONLY IF -- the disk image is read-only.

Most filesystems -- including HFS+ -- are designed with the assumption that the system mounting the filesystem has exclusive access to the filesystem. Attempting to mount a HFS+ filesystem as read/write from multiple systems will likely result in multiple systems trying to update data in the same locations on disk, causing catastrophic filesystem corruption.

The safest way to ensure that the image is always mounted read-only will be to create it as a compressed disk image, or write-protect it directly on the server. If these options are not available, use

hdiutil attach -readonly ...

to mount it on the client.

  • What command/option does the OP need to mount an image read-only? – nohillside Feb 28 '19 at 6:33
  • @nohillside If the disk image is in a read-only format, no special option is needed. If the image is in a read-write format, you can override that with hdiutil attach -readonly ... – Gordon Davisson Feb 28 '19 at 7:17
  • @GordonDavisson It might help future visitors if this would be part of the answer. – nohillside Feb 28 '19 at 7:19
  • @nohillside As I hinted at in the last paragraph of my answer, the most reliable way of accomplishing this will be to use a disk image format that is inherently read-only, like a compressed image. Using a command-line option to set a writable image as read-only leaves the risk that a user will accidentally mount the image read-write by double-clicking it. – duskwuff -inactive- Feb 28 '19 at 7:19
  • The image is on Win Server in Shared folder...the sharing permission level is "read" for everyone. So I assume that users have only read access to that file :) – Dmytro Feb 28 '19 at 7:51

You must log in to answer this question.

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