Read/Write to hfs+ on Ubuntu
August 17th, 2009
Recently I re-configured my setup for more convenient dual-booting between Mac OS & Ubuntu Linux. I created a common hfs+ partition that both Ubuntu and Mac OS share, and this is my main storage for my work.
It took a bit of finagling to get Ubuntu Linux writing to the hfs+ drive, so I wanted to share my experience for those who might benefit from it.
Furthermore, I experienced a wierd issue where, while running Ubuntu my computer improperly shut down, and the hfs+ drive was no longer writeable. Below is how I fixed that.
Setup
Mac OS Leopard on hfs+ journaled partition
Ubuntu 9.04 on ext4 partition
Common hfs+ (unjournaled) partition for sharing data
Prepare Ubuntu
I found everything I needed to mount an hfs+ drive already installed on Ubuntu. But write support was not working be default. So I edited my /etc/fstab to include this as the last item, and it mounts the drive with read/write permissions.
/dev/sda3 /mnt/common hfsplus user,auto,uid=1000,gid=1000 0 0
From what I found about fstab, here’s what all that means:
- “/dev/sda3″ is the path to the drive’s partition
- “/mnt/common” is the location I want to mount the drive at
- “hfsplus” is the partition type
- “user” allows a normal user (not just root) to mount this drive
- “auto” means mount automatically when booting
- “uid” is my user’s id, allowing it access to this mount point
- “gid” is my user’s group id, allowing that group access to this mount point
- The two zeros at the end…
- zero 1 is the dump option: “should this be backed up?” Zero means “no”
- zero 2 is the order in which fsck should check the filesystems. Zero means “don’t check”
One caveat, I had to adjust the permissions on all files that I want read & write access to in both operating systems. Otherwise, when Ubuntu saved a file, OS X only had read permission, and vise-versa.
Here’s the command that recursively sets permissions an all files in the common drive to 777:
sudo chmod -R 777 /mnt/common
Fix hfs+ read/write when improperly shut down
Once, after hibernating my computer in Ubuntu, it would not wake up, so I force-restarted. Evidently this caused the common partition to have an improperly-unmounted flag that would not let Ubuntu write to it. After booting into OS X and restarting into Ubuntu, it worked. I guess booting into Mac OS reset that flag…but I’m not entirely sure. But it did fix my read/write access to my hfs+ partition
August 18th, 2009 at 1:04 pm
[...] Read & Write access to hfsplus (hfs+) drives in Ubuntu How to set up Ubuntu to have read and write access to a Mac OS hfsplus (hfs+) partition. (tags: Ubuntu lunix hfs+ OSX filesystem) Dieses Werk ist, wenn nicht anders angegeben, lizensiert unter einer Creative Commons Attribution-Noncommercial-Share Alike 2.0 Germany License. Keine Tags für diesen Beitrag gefunden. [...]
October 1st, 2009 at 5:23 pm
[...] Linux: Enabling HFS writing in Ubuntu [...]
December 30th, 2009 at 5:15 pm
Good tip for a fast sharing partition.
The only thing I would add to this is actually a warning, because setting permissions 777 means anyone will be able to read and write all of your files, which might be a security issue if for some reason you are concern about privacy.
A walk around this is to set your user in both systems to have the same name AND the same UID (user-ID).
In Mac OSX, default user-ID is 501, while in Ubuntu is 1000. Change one (or both) of those in order to match them. This way you don’t have to use permissive rights to all of your documents.