Dealing with Mac-formatted drives on Linux

  • September 12, 2007
  • Avatar for peter
    Peter
    Upfold

If you deal with Macs at all, you might be curious as to whether Linux is capable of dealing with disks and drives formatted for Mac OS X. The answer is - yes, in most cases, and it is actually quite easy to get your Mac-formatted stuff mounted on your Linux system with read-only, and in most cases read-and-write, support.

In most modern distributions, the capabilities for mounting media formatted with Apple's HFS and HFS+ filesystems is actually built in, and you don't need to install any special software. However, most distributions do include a package called hfsutils which might come in handy if you'll be regularly dealing with HFS/HFS+ formatted media. You should be able to install it by searching for that in your distribution's package manager.

Mounting a Mac-formatted volume

Whether it's an optical disc, external drive or other storage device, mounting a Mac-formatted volume usually is pretty simple. Depending on your exact setup, it might be as easy as plugging in or inserting the media and having it automatically pop onto your desktop. If this is the case, great! You can get started straight away, no more configuration needed.

Sometimes this doesn't work however. Usually, mounting the volume should be a simple process of following the usual command line mount procedure (as root, or sudo-prefixed). In this example, I'll mount my external drive (at /dev/sda1) to a folder:

# mkdir /mnt/macdrive
# mount -t hfsplus /dev/sda1 /mnt/macdrive

At this point, you should get at least read support, or you may get read-write (but will need to be root to write to the volume).

Some read-write caveats

In my experience, Linux writing to HFS and HFS+ is extremely reliable (thanks to Apple's relatively open documentation of their technology and the open source implementations of the filesystem). There are some cases, however, where you won't be able to write to the drive.

Particularly, newer volumes that use HFS+ with Journaling can't be safely written to under Linux. Since Mac OS X 10.4, your Mac's boot drive will have journaling on by default and it's possible that formatting drives with the default Mac OS Extended option under OS X's Disk Utility will turn Journaling on.

There is a way to retroactively disable Journaling on an HFS+ drive however if you're determined to write to it in Linux. Bear in mind that this process is potentially risky and definitely don't do it on your boot drive. From the Mac OS X Terminal, run this:

$ sudo diskutil disableJournal "/Volumes/nameofdisk"

Now the journaling feature is disabled, Linux should be able to get full write access safely.

Troubleshooting

If you're experiencing problems with mounting Mac-formatted volumes, you might want to remember these things.

$ dmesg | tail

The above command is definitely your friend when dealing with filesystems. If for some reason a mount fails, or you get read-only access when you wanted read-write, looking at the output of dmesg can prove extremely useful in helping you find a solution.

Also, remember to check your permissions if you can't write to something. If in doubt, try it as root before moving onto attempting to troubleshoot (also remember you can mount with -o uid=youruserID to force ownership if you know how.

Avatar for peter Peter Upfold

Home » Articles »