Sunday, January 20, 2013

When chown does not work silently on MacOS

Each Unix flavor has its very own personality.

Today, with MacOS, I spent two hours searching why a  sudo chown -R did not work properly on a directory tree.

Exit code: 0
Error message: none

Nothing done ! My files remained, try after try, with their original ownership which was:

_unknown:_unknown

Mysticism.

Some context: these files, located on an external drive (MacOS extended formatted), resulted from a tar copy of a user account folder contained on a disk which belonged to an early 2008 MacBookPro who just died from a Nvdia attack a few weeks after the limit (The NVIDIA GeForce 8600M GT graphics processor repair extension program ended on December 7, 2012. Sigh). 

I found the answer when I realized that the external property of the drive was the key. The solution was here (verbatim):

From the output, it is clear that the drives have "ownership" disabled, or owners aren't supported under OS X (eg. if the drive is FAT formatted).

When ownership on a volume is disabled, everything is treated as if it is owned by the user and group "unknown" ('uid' and 'gid' 99). Items owned by "unknown" have the property of appearing to be owned by the owner of the process attempting to access the item, and only "root" can see their true nature (in 10.4 and later). In this context, 'chown' isn't meaningful.

To see if ownership is enabled, use "Disk Utility.app", and possibly "Get Info" in the "Finder". Or else, on the command line, eg:<pre>
vsdbutil -c /Volumes/terra</pre>

Ownership can be enabled (assuming the volume format supports it) using the GUI, or with eg.:<pre>
/usr/bin/sudo /usr/sbin/vsdbutil -a /Volumes/terra</pre>


I do not know who you are, biovizier (the author of the answer), but I thank you very very much !

What I did not understand though was the fact that this kind of chown was working the day before on the same drive ... I certainly did something wrong (no more mysticism !), but I still do not know what ...

Oh ? And what about TimeMachine to recover lost stuff ? No luck this time: backup was restarted from scratch since a few days on the laptop before it died, and it was still "in progress". I was unaware of the danger: in this case, your only fresh full backup is your hard drive (as TimeMachine was still in the way, the "in progress" data contained only 30GB out of 160GB). Shiver.

My advice: when TimeMachine restarts the backup from scratch, put right away your laptop on the wire to accelerate the backup and think about the last time you did a SuperDuper clone of it ...

No comments:

Post a Comment

Please, enter your comments bellow