Wednesday, April 26, 2006

USB Memory Devices and Mac OS X

For many years (about 13) I had a low user id number on my various Unix boxes of 112. This was a hangover from the old days of Sun OS 4.1.3 when anything under 100 was restricted. I carried this uid from Sun OS to Solaris to Linux to Mac OS X because I routinely used NFS (which operates on the uid) and didn't want my systems administrators to have to change my uid on all file servers.

I finally made the switch to a high uid (above 500 - the new standard) when I bought a PowerMac G5 last year. That made switching the files from my Powerbook G4 much more difficult, but not impossible. I thought I was done.

Then something strange happened. In a seemingly unrelated series of events, my three USB memory sticks started to leak capacity. A particular 1 GB stick would only hold 40 MB, even though there were no files on it! I found the problem today. My old uid had raised its head one last time.

Mac OS X segments files on removable media by - you guessed it - uid. The file structure on the 1 GB USB stick had these files on it:
[macaw]$ file .*
.: directory
..: sticky directory
.DS_Store: data
.TemporaryItems: directory
.Trashes: directory
._.TemporaryItems: AppleDouble encoded Macintosh file
._.Trashes: AppleDouble encoded Macintosh file
The .TemporaryItems and .Trashes directory were full of files owned by my old uid - which my new uid had no right to delete. The solution was to use sudo on the command line to simply remove those directories and their associated files (including the top-level ._.* files). Ejecting the device and remounting it showed a comfortable 976.1 MB.

No comments:

Post a Comment