Trouble Accessing Mac OS X Partition from Ubuntu 14.04
If you have gone and changed your
uid
andgid
, 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
orgid
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 videos on Youtube
bzodonnell
Updated on September 18, 2022Comments
-
bzodonnell over 1 year
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.
EDIT: Per Thomas W.'s suggestion, I ran
sudo ls -al folder
, wherefolder
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.
-
Terrance almost 9 yearsI don't know if you have the answer yet or not. I pulled my drive out of my MacBook Pro, and I am able to access my drive without having the
hfsplus
installed in my Ubuntu, and the drive is formatted as HFS+. However, I am not able to access any of the folders in my/home/username
area unless I launch my Nautilus as an elevated user. Try typing in from a terminal windowsudo nautilus
and then see if you can access the contents of that drive. -
Terrance almost 9 yearsIt is external right now. It did, however, only mount it as read only. It does that to protect the files. I can read any files from within any of the folders though. I just unmounted it, and remounted it using the command
mount -t auto /dev/sdh2 /media/OSX/
where sdh2 is the partition that the HFS+ is. It mounts it as read only. You can runblkid
from a terminal window to show what all the partitions are formatted as and what their/dev/sdX
designations are. -
Terrance almost 9 yearsI think you may have commented on the wrong one. You need to unmount the partition first
sudo umount /dev/sda2
, then try the command. -
bzodonnell almost 9 yearsI seem to have full read access with sudo nautilus - though I don't have write access to modify files under nautilus or otherwise. (Note also that I do have a full Time Machine backup that I could use to restore my Mac OS X installation if this did screw things up - so I'm more just trying to get a solid understanding here than worrying about my files.)
-
bzodonnell almost 9 yearsOh, I don't want to write; I just want to be able to read the files, and wanted to have a better understanding of whether I would damage my OS X installation in doing so. I think this is outside the scope of the current question though, since Thomas's solution worked (with your clarification to use umount first). I'll open a new question topic to get a comprehensive answer to my chown concerns, hah.
-
Terrance almost 9 yearsSounds good! Good luck on your learning!
-
-
bzodonnell almost 9 yearsThank you! Just a few clarification questions: 1) When I type sudo mkdir -R /media/username/MacOS (replacing my username, of course), I get that R is an invalid option. 2) When replacing USERID and USERGID, am I replacing with the UID and GID for my Ubuntu user (both 1000), or for my Mac user (501 and 20)? I assume it'd be the mac ones, but I just want to check. Also, how easy is it for me to break permissions by changing uid and gid? I've barely used Ubuntu (just installed it today, actually). Would it be best for me to do a clean install, or is it probably fine if I made sure to use chown?
-
Thomas Ward almost 9 years(1) This is to be run on your Ubuntu partition. Try
-p
instead. (2) UID and GID are for the Ubuntu user not the Mac user - this says you want the system to mount with UID/GID for Ubuntu. Mac is evil with perms though. Read the man page for mount options and learn what they do. (3) As long as you change your uid and gid back to what they were breakage should be minimal. If you are really concerned then do a fresh Ubuntu reinstall. It's insanely easy to break permissions if the wrong uid or gid is set which is why I put so much emphasis to my warning at the beginning of my answer. -
Thomas Ward almost 9 years@bzodonnell See my previous comment for the answer to your follow ups.
-
bzodonnell almost 9 yearsYeah, thanks; much appreciated. I suspect the breakage was minimal, since all I did was change the permissions, realize it didn't work, and change them back. I used chown on my (empty) home folder each time, so I'm probably fine. Running the chown command on the media folder now. Will let you know if I have any more questions after it ends.
-
bzodonnell almost 9 yearsRunning the
chown
command gave me access to most folders on the Mac partition, but I still get a "This location could not be displayed" error when trying to access Desktop, Documents, Downloads, Library, Movies, Music, or Pictures. Is there anotherchown
command I'd have to do to get access to these folders? -
bzodonnell almost 9 yearsI added a screenshot to my post of what I'm seeing lately after running
chown
andmount
. -
Thomas Ward almost 9 years@bzodonnell
sudo ls -al
the folder before Documents. Include the output in an edit to your question. -
bzodonnell almost 9 yearsAll right, I edited it into the post above.
-
Thomas Ward almost 9 years@bzodonnell And you mounted with
uid=youruseruid,gid=yourgroupid
as options at the time of mounting? -
bzodonnell almost 9 yearsYep. Added the code I typed before
sudo ls -al
above. -
Thomas Ward almost 9 years@bzodonnell make sure
hfsplus
is installed too - the drive is read only apparently so it might not be able to use the uid / gid -
bzodonnell almost 9 yearsJust installed it. However, when I view the Documents folder or use
ls /media/bzodonnell/MacOS/Users/bzodonnell/Documents
, I get a "Permission denied" message unless I usesudo
. Also, just to clarify: I don't want to disable journaling (which would allow me to write to the HFS+), and I don't want to write to the drive; I just want to be able to read the files. I can get to them withsudo nautilus
too, so I know that it's possible. Just not quite sure how to do it, hah. -
Thomas Ward almost 9 years@bzodonnell It's possible it's expecting the permissions to be with the Mac side of things. The Linux permissions there restrict it to owner. It's my guess that the journaling system there is enforcing the original permissions structure from Mac, and the only way to change that is to change it from Mac. I'd suggest booting to Mac, and setting the group to have +rx on the folders, then go back to Ubuntu and add your user to the 'dialout' group (
sudo usermod -a -G dialout
), then try and access. If Mac forbids you to do this, then you'll have to go and mess with a lot more file perms. ... -
Thomas Ward almost 9 years... Note though that the Mac permission system is definitely weird and causes a lot of confusion to everyone, even, so... :/