Apple - Change "ignore ownership on this volume" from the command line for Mac OS X volume

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

I found that both answers worked for enabling ownership in way that is remembered:

sudo diskutil enableOwnership <diskname>s<slicenum>

And:

vsdbutil -a /Volume/<volname>

However, the opposite is not true, at least on OS X 10.11.3:

sudo diskutil disableOwnership <diskname>s<slicenum>

And:

vsdbutil -d /Volume/<volname>

Both temporarily change the state, but ownership is re-enabled next time I mount the volume. This appears to be a bug in the operating system. Fortunately I found a solution that works. Eject all external disks that you want to disable ownership for. Then delete the appropriate database using:

sudo rm /var/db/volinfo.database

Use vsdbutil to set it for a path instead of a physical drive:

vsdbutil -a /Volume/Diskname

Although the man page suggests it is deprecated, the man page for diskutil still refers to it and the mechanism appears to be based on Volume UUIDs not on physical disk/slice ids.