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:

  1. “/dev/sda3″ is the path to the drive’s partition
  2. “/mnt/common” is the location I want to mount the drive at
  3. “hfsplus” is the partition type
  4. “user” allows a normal user (not just root) to mount this drive
  5. “auto” means mount automatically when booting
  6. “uid” is my user’s id, allowing it access to this mount point
  7. “gid” is my user’s group id, allowing that group access to this mount point
  8. The two zeros at the end…
    1. zero 1 is the dump option: “should this be backed up?” Zero means “no”
    2. 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 :)

3 Responses to “Read/Write to hfs+ on Ubuntu”

  1. links for 2009-08-18 | chris-b online Says:

    [...] 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. [...]

  2. Playing Nice with Filesystems « The Wheat Field Says:

    [...] Linux: Enabling HFS writing in Ubuntu [...]

  3. Fabio Bugnon Says:

    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.

Leave a Reply