32

I installed Ubuntu and Windows on my MacBook and Ubuntu is my primary OS; however, all of my media stays on my OSX partition. I want to be able to access it (at least my OSX user's home folder) from Ubuntu without having to launch a media player (or anything else) as root. Also, because I occasionally want to fire up my machine in OSX, I don't want to change anything that I would need to change back frequently (I read a lot about changing UID--I don't exactly understand what this entails, but I wouldn't want to have to change my UID back and forth depending on which OS I'm using. Similarly, I don't want to change file system permissions back and forth).

Also, I saw something about a "noowner" option, but that doesn't seem to do what I want it to.

So I guess I'd like to be able to do something like this:

sudo mount -t hfsplus -o noowner /dev/sda2/ /media/Mac

And then be able to access all of my media (at least everything in my OSX user's Home folder) without dropping in as root. (for clarity: the above command line entry doesn't do what I want it to do, but I want to be able to do something similar).

Or would it be better to change my UID? And if so, how?

2
  • Can you take a look at my answer. I believe I've answered your question more correctly than the marked answer.
    – Catskul
    Mar 19, 2014 at 21:15
  • @Catskul No I can't. This question is over 2 years old--in that time, I've sold my MacBook and reproducing this issue for the purpose of validating your answer is prohibitively difficult.
    – weberc2
    Mar 20, 2014 at 15:06

6 Answers 6

34

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
3
  • The load on cpu and memory is quite substantial, though. If that's a concern, I would recommend @weberc2's solution. Otherwise great answer.
    – frhd
    Jun 24, 2014 at 14:43
  • bindfs has been flaky for me. i used the response for this post askubuntu.com/questions/315078/… instead Feb 9, 2015 at 9:25
  • Good answer (upvoted) but It requires to install bindfs. Why that isn't so good? Well, this is my unusual case: friend gives me old MacBook (I don't know if Pro) to backup data from non booting MacOS. I try latest Ubuntu version and no luck (nouveau driver crash, nomodeset doesn't help). Then I start going back with Ubuntu versions until I find one that boots, 9.10 (yeah), repo servers aren't online anymore. bindfs cannot be installed. The accepted answer solves that problem. May 28, 2016 at 3:05
21

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 from 1000 to 500.
  • 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.
5
  • the usermod approach worked for me. just make sure to remove /media/USERNAME if you want to use USB drives. askubuntu.com/questions/583375/… Feb 9, 2015 at 16:05
  • For your caveat 1, 700 is indeed the default for user directories in OS X, but there's no problem in changing it if it doesn't suit you, for example to 755.
    – fkraiem
    Dec 13, 2015 at 22:35
  • While using sudo to issue commands and launch nautilus with sudo allows access to any directory in the MacOS HD, the uid method is the best when you need more than simply access the files, for example transfer them to a shared folder in another machine (using samba, for example). The elevated nautilus instance cannot explore the network, a normal nautilus instance can, but it doesn't let you copy and paste from the MacOS HD. Give a tempuser the uid 501 solved the problem for me, allowing me to backup data from a non booting MacOS to a shared folder. May 28, 2016 at 3:15
  • For 16.10, except UID_MIN, also need to add GID_MIN=500 to /etc/login.def
    – draw
    Feb 19, 2017 at 16:50
  • After following the above steps my normal user account vanished?
    – Taha Malik
    Dec 30, 2020 at 10:46
4

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).

4
  • I've been trying to do that, but I don't know what UID I should be using. I've read it's something like 501 for OSX, but the account isn't the original OSX user. How can I find out this information?
    – weberc2
    Feb 22, 2012 at 17:14
  • @weberc2: ls -l /media/YourHFSdisk/ will show you the uid and gid of the current files/folders. The HFS+ disks I come across seem to be mostly owned by uid 99 and gid 99. However, I tried various combinations uid/gid/umask settings in the mount command, and it didn't seem to change anything.
    – mivk
    Nov 18, 2012 at 22:56
  • 1
    This did not work for me. From documentation: "uid/gid\nSpecifies the user/group that owns all files on the filesystem that have uninitialized permissions structures." Unfortunately, all the files on my filesystem are still owned by 501 (ie they have initialized permissions structures (?))
    – Colin
    Sep 18, 2014 at 21:26
  • apfs-fuse also has similar option. See github.com/sgan81/apfs-fuse and linuxnewbieguide.org/…
    – Ashark
    Feb 19, 2020 at 1:29
4

I know this is old, but there is another way around it that seems to work just fine for me. Since all of the files were owned by a "root" user, all I did was issue su root from the terminal and ls -lah /media/Macintosh HD from there. By using root, I was able to bypass the permission denied error.

1
  • simple and devious
    – SYK
    Jun 3, 2015 at 4:19
1

This is general option I am using works perfectly

mkdir /media/test
mkdir /media/diskhfs
mount /dev/sdb1 /media/test -o rw
bindfs -o perms=775,mirror=userorid --map=99/userorid:@99/@uderorid /media/test /media/diskhfs
1

I was able to get access to files from an old Macbook hard drive by running the file manager with elevated privileges.

gksudo thunar

Then copy files as needed.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .