MacOS – Cannot change owner and group of file mounted disk image

hfs+macossparsebundle

I have an external disk which (for other reasons) is formatted using FAT32. On that disk I have created a sparse bundle image formatted using HFS extended (journaled). This image is then mounted on /Volumes/TestDisk.

$ sudo hdiutil attach -mountpoint /Volumes/TestDisk /Volumes/FAT32DSK/TestDisk.sparsebundle/
$ ls -l /Volumes
total 72
drwxr-xr-x  9 mgd   staff    374  7 Jun 22:48 TestDisk
lrwxr-xr-x  1 root  admin      1  4 Jun 17:02 Macintosh HD -> /
drwxrwxrwx  1 mgd   staff  32768  7 Jun 22:21 FAT32DSK
$ 

Whenever a file is created on the mounted disk, it gets me as owner – also if I create the file as root:

$ touch myfile
$ sudo touch rootfile
$ ls -l
total 0
-rw-r--r--  1 mgd  staff  0  7 Jun 23:00 myfile
-rw-r--r--  1 mgd  staff  0  7 Jun 23:00 rootfile
$ 

If I try to change the file owner afterwards, nothing happens:

$ sudo chown root:admin rootfile 
$ ls -l
total 0
-rw-r--r--  1 mgd  staff  0  7 Jun 23:00 myfile
-rw-r--r--  1 mgd  staff  0  7 Jun 23:00 rootfile
$ 

Changing permissions apparently works fine but the owner/group cannot be changed.

I am running Mac OS X Lion 10.7.3.

What did I do wrong?

Best Answer

If the disk is mounted to ignore file ownership, the owner is always reported as the current user, and cannot be changed. Attempting to change the owner will not produce an error message, but simply fail silently.

In the Finder, select the mounted disk corresponding to the sparse image in question and Get Info (I). At the bottom of the pane that opens, see if it looks like this: (i.e. the Ignore ownership on this volume box is checked)

enter image description here

If you uncheck that box, you should get the behavior you seek.