Ubuntu – Trouble Accessing Mac OS X Partition from Ubuntu 14.04

macmountpermissions

I have a 1 TB hard drive in a Macbook Pro 6,2 (mid-2010) partitioned with 900 GB for Mac OS X and 100 GB for Ubuntu 14.04. I would like to be able to read the files off the HFS+ partition with OS X installed to listen to my music, watch video files, etc.

I changed my Ubuntu account's UID by logging into a second account I created with sudo privileges and running the following (where username is my login username):

sudo usermod -u 501 -g 20 username
sudo chown -R username: /home/username

When I logged back in, I still got the "You do not have the permissions necessary to view the contents of 'Macintosh HD'." In my troubleshooting efforts, I changed my primary account's UID and GID back to 1000 and made a new user account on which I changed the UID and GID. This account now has read access of the HFS+ volume – but when I deleted it and did the exact same thing for my primary account, I got the same error.

Is it possible to change the UID and GID of my primary account to give me access to read the HFS+ volume?

EDIT: Here's a screenshot of the issue when I try to access Documents. The same error occurs for Desktop, Downloads, Dropbox, Google Drive, Library, Movies, Music, and Pictures – but not any of the other (visible) folders. Haven't tried to get into /.wine or anything.

Here's a screenshot of the issue.

EDIT: Per Thomas W.'s suggestion, I ran sudo ls -al folder, where folder is the folder in which Documents is placed. This is the output:

bzodonnell@bzodonnell-MacBookPro:~$ sudo ls -al /media/bzodonnell/MacOS/Users/bzodonnell
total 232
drwxr-xr-x 1  501 dialout     61 May  4 15:57 .
drwxr-xr-x 1 root      80      5 Oct 20  2014 ..
drwxr-xr-x 1  501 dialout     20 Apr  7 13:11 adarkroom
drwxr-xr-x 1  501 dialout     15 Mar  5 09:27 .android
drwxr-xr-x 1  501 dialout      7 Mar  9 18:44 AndroidStudioProjects
-rw-r--r-- 1  501 dialout    638 Feb 17  2014 .anyconnect
drwxr-xr-x 1  501 dialout     90 May  5 11:48 Applications
-rw------- 1  501 dialout  18776 May  5 16:56 .bash_history
-rw-r--r-- 1  501 dialout    334 Oct 29  2014 .bash_profile
-rw-r--r-- 1  501 dialout    167 Jul 10  2014 .bash_profile.pysave
drwxr-xr-x 1  501 dialout      7 Apr 30 13:11 .cache
drwxr-xr-x 1  501 dialout    156 May  2 13:13 Calibre Library
-r-------- 1  501 dialout      7 Apr  4 11:10 .CFUserTextEncoding
drwxr-xr-x 1  501 dialout      4 Mar  6  2014    .com.stirfirestudios.freedomfall.macos
drwxr-xr-x 1  501 dialout      7 Apr 19 14:17 .config
drwx------ 1  501 dialout      3 Sep  8  2010 .cups
drwxr-x--- 1  501 dialout      6 Apr 15 15:12 .denemo-1.2.2
drwx------ 1  501 dialout     14 May  6 17:04 Desktop
drwx------ 1  501 dialout     19 May  5 11:09 Documents
drwx------ 1  501 dialout    207 May  5 15:13 Downloads
drwx------ 1  501 dialout     12 May  7 08:16 .dropbox
drwx------ 1  501 dialout     73 May  7 09:23 Dropbox
-rw-r--r-- 1  501 dialout  22532 May  5 15:17 .DS_Store
drwx------ 1  501 dialout      3 Apr 14 18:01 .emacs.d
drwxr-xr-x 1  501 dialout     45 Apr 15 14:46 .fontconfig
drwxr-xr-x 1  501 dialout     10 Apr 27 19:25 .git
-rw-r--r-- 1  501 dialout    151 Apr  7 13:24 .gitconfig
drwx------ 1  501 dialout      2 Apr 15 14:44 .gnome2
drwx------ 1  501 dialout     43 Jun 18  2014 Google Drive
drwxr-xr-x 1  501 dialout      4 Feb 26 10:59 .gradle
drwxr-xr-x 1  501 dialout      4 Oct 29  2014 .idlerc
drwxr-xr-x 1  501 dialout      8 Apr 15 14:44 .inkscape-etc
-rw------- 1  501 dialout     35 May  3 17:02 .lesshst
drwx------ 1  501 dialout     71 Apr  4 11:10 Library
drwxr-xr-x 1  501 dialout      9 Apr 15 15:12 .lilypond-fonts.cache-2
drwxr-xr-x 1  501 dialout      3 Feb  9 11:18 .local
drwx------ 1  501 dialout      8 May  2  2011 Movies
drwx------ 1  501 dialout      9 Feb 20 10:33 Music
drwxrwxrwx 1  501 dialout      3 Jul  2  2014 .nchsoftware
drwxr-xr-x 1  501 dialout      9 Apr 30 14:09 PCSX2
drwxr-xr-x 1  501 dialout     11 Apr  6 10:18 .pia_manager
-rw-r--r-- 1  501 dialout 130030 May  7 09:54 .pia_manager_crash.log
drwx------ 1  501 dialout     11 Apr 16 07:10 Pictures
drwxr-xr-x 1  501 dialout      6 Jul 10  2013 Public
drwxr-xr-x 1  501 dialout      6 Apr 15 23:39 .qgis2
drwxr-xr-x 1  501 dialout      3 Feb 20  2014 .R
-rw-r--r-- 1  501 dialout    225 Dec  3  2013 .Rapp.history
-rw-r--r-- 1  501 dialout  16419 Feb  9 14:02 .Rhistory
-rw------- 1  501 dialout   1024 May  3 17:25 .rnd
drwxr-xr-x 1  501 dialout     16 Feb 19 17:24 .rstudio-desktop
drwxr-xr-x 1  501 dialout      6 Jul  3  2014 Sites
drwxr-xr-x 1  501 dialout      8 Apr 15 13:45 stencylworks
-rw-r--r-- 1  501 dialout    123 Apr 15 13:52 StencylWorks.prefs
drwxr-xr-x 1  501 dialout      6 Jun  1  2012 .subversion
drwxr-xr-x 1  501 dialout      4 Apr 14 22:31 .thumbnails
drwx------ 1  501 dialout     25 May  6 16:59 .Trash
-rw------- 1  501 dialout    849 Apr 14 18:00 .viminfo
drwxr-xr-x 1  501 dialout      8 May  4 15:59 .wine
drwxr-xr-x 1  501 dialout     10 May  3 19:51 .wine-brothers
drwxr-xr-x 1  501 dialout      9 May  1 09:25 .wine-steam
-rw------- 1  501 dialout      0 Apr 20 18:17 .Xauthority

EDIT: Here's what I'm typing to make sure the directory is mounted properly. I typed this before I ran the above code.

bzodonnell@bzodonnell-MacBookPro:~$ sudo umount /dev/sda2
bzodonnell@bzodonnell-MacBookPro:~$ id
uid=1000(bzodonnell) gid=1000(bzodonnell) groups=1000(bzodonnell),4(adm),24(cdrom),27(sudo),30(dip),46(plugdev),108(lpadmin),124(sambashare)
bzodonnell@bzodonnell-MacBookPro:~$ sudo mount -t hfsplus -o uid=1000,gid=1000 /dev/sda2 /media/bzodonnell/MacOS
mount: warning: /media/bzodonnell/MacOS seems to be mounted read-only.

Best Answer

If you have gone and changed your uid and gid, go and change them back now before even going past this first part of this answer.

Unless you really know what you're doing, you should NEVER go change your uid or gid just to mount a drive, as you can break other permissions in the computer and potentially lose access to your own home directory in the Linux partition.


Usually when you mount a drive, you pass arguments to provide the uid and gid as options for the mount to specify user/group ownership, as well as other important permission mask arguments, and other arguments (this is most typically done with vfat or ntfs partitions, but it applies to most partition types, especially ones which don't respect the Linux permissions systems). While this is usually done as part of the /etc/fstab file for persistent options for specific partitions or media, you can manually provide options for a given mount command if you wish.

Mounting with the following command should do what you need it to do without modifying your own user's UID or GID. This makes a MacOS folder in /media/username/, where we'll mount the drive partition to:

sudo mkdir -R /media/username/MacOS
sudo chown --recursive username:username /media/username
sudo mount -t hfsplus -o uid=USERUID,gid=USERGID /dev/sdx /media/username/MacOS

Replace /dev/sdx with the actual partition identifier, and all instances of 'username' with the user's name. Similarly, replace USERID and USERGID with the actual values there.

To make it persistently user mountable, you should add an fstab entry that allows users to mount and unmount the drive, while providing the uid and gid accordingly.

(Note: the uid and gid arguments were obtained from kernel.org documentation. You must have the prerequisite libraries to read hfsplus partitions to make this work.)

Related Question