By-passing default permissions when mounting HFS+ volumes in linux

Solution 1:

bindfs is the answer. It will take an already mounted file system and provide a view of it with whichever uid you'd like:

sudo apt-get install bindfs
mkdir ~/myUIDdiskFoo
sudo bindfs -u $(id -u) -g $(id -g) /media/diskFoo ~/myUIDdiskFoo

Edit:

Also, reading the doc I realized that the map option (1.10 and later) might fit better:

sudo bindfs --map=502/1000 /media/diskFoo ~/myUIDdiskFoo

Solution 2:

In the end, I created a linux user with the same UID of my mac os x user, but it can't browse every directory in my home on mac hfs+ volume because a lot of files were owned by mac user "unknown", UID 99 (see http://googlemac.blogspot.com/2007/03/user-99-unknown.html).

It seems that they did so to let you mount and read your volume when you connect it to a different computer. When a regular user look at those files owned by UID 99, he sees them as he is their owner. Quite strange. Only root sees them as they are.

So I rebooted in Mac Os X, logged in with a different user with administrative privileges and used chown -R 502:20 /Users/gerlos/* to change the owner of every file in my home. Now I can read everything without any problem.

Remarks:

  • default kubuntu gui tool to create new users on Kubuntu 11.10 can't create users with UID less than 1000. Use adduser on the terminal instead.
  • you can know your user UID using the "id" command on the terminal.
  • on mac os x, you need to be root to see the real owner of the files. So expect different results if you type "ls -n /Users/gerlos" and "sudo ls -n /Users/gerlos".