How to mount HFS+ drive and ignore permissions
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
I wasn't able to figure out how to ignore the permissions, but I ended up changing the UID on my Ubuntu account to match my OSX account:
sudo useradd -d /home/tempuser -m -s /bin/bash -G admin tempuser
sudo passwd tempuser
Enter new password. Log out, log in as "other" with username "tempuser" and the password you chose earlier. Open a terminal and type:
sudo usermod --uid 501 yourusername
sudo chown -R 501:yourusername /home/yourusername
*change "yourusername" to your non-temporary user name and 501 to the UID of your Mac account (first Mac account starts at 501, but subsequent users will have different UIDs).
Log out of tempuser and log back into your normal account (this is important; don't just switch users--bad things happen). Open a terminal window and type:
sudo userdel -r tempuser
For more details, visit this page.
Caveats
- Only one linux user can gain access. This setup will not allow multiple linux users to access multiple user directories on the HFS+ drive. This is because Apple locks down user directories (and media directories like Music) to 700 (
rwx------
). - Once you change your UID the login manager will stop listing that user. You have to change the
UID_MIN
option in/etc/login.def
from1000
to500
. - Finally because the user UID has changed, access to the drive becomes a permissions confusion. You will have to note the exact location of your user's home folder to view it. Tab completions and browsing through the file manager will become problematic to folders outside the original Apple user's home folder without
sudo
.
The documentation for the linux kernel implementation of the HFS+ filesystem lists a uid
mount option that allows you to "own" all files (and maybe some other options that might be useful too).