Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

(This question is a spin-off of another question I asked on this site.)

New images always ignore owner/group

When creating a new disk image from Disk Utility it is automatically mounted. If you then select the volume in Finder and press Cmd-I (for the info window) you will see this at the bottom of the window:

enter image description here

This means that file owners and groups will be ignored on this volume. This is very convenient for external drives being shared between machines with different user accounts on them. For a backup volume it is not a good idea as you would like to retain the owner/group information for the files backed up.

Change this from Finder

To change this, simply uncheck the checkbox and it will remembered after you eject and remount the image.

Change from command line (Terminal)

Instead of mounting the image from Finder, you can also mount it from the command line using this command (assuming the image is called testimage.sparsebundle):

$ hdiutil attach testimage.sparsebundle/

Still, owners are ignored on the volume. Adding the -owners on option is (almost) equivalent to unchecking the checkbox in the image above:

$ hdiutil attach -owners on testimage.sparsebundle/

However, after unmounting and remounting the volume from Finder (or from the command line without the -owners on option), the checkbox is checked again.

Does anybody know how to make this change persistent using a command-line call?

share|improve this question

1 Answer 1

up vote 7 down vote accepted

You use diskutil for that. See diskutil(1) under enableOwnership and disableOwnership. Note that this setting is specific to a particular operating system installation, since it is stored in /var/db/volinfo.database. I.e., if you copy the disk image to a new computer the setting won't persist, but it does persist across reboots, mounts, umounts, etc. all on a single computer.

Use diskutil to find the identifier, then change the option:

$ diskutil list
/dev/disk2
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:                            Disk Image             *41.0 MB    disk2
$ sudo diskutil enableOwnership disk2
File system user/group ownership enabled
share|improve this answer
    
Thank you for a concise answer! –  mgd Jun 8 '12 at 20:02
1  
This isn't completely accurate - diskutil is going to tell you that you need to specify a disk with a mount point, meaning that you have to point it to the slice for the volume you want to rename. The correct syntax (assuming slice 2 of disk 2) would be: sudo diskutil enableOwnership /dev/disk2s2 If you run: sudo diskutil list you'll be able to see all the disk information, and find the correct disk & slice for your volume. –  user27585 Aug 17 '12 at 13:14
    
I have found that I must re-invoke diskutil enableOwnership between mounts, or else I cannot execute binaries and scripts on the mounted volume. –  psoft Oct 24 '12 at 19:31

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.