HFS and HFS Plus in FreeBSD

An Important Note on the Current Status of This Project

With very little motivation left to keep this project alive, I've put it on hold. Should you wish to resume it, you can use my last CVS snapshot as your starting point. Be warned, however, that its value is decreasing as new versions of Darwin are being released by Apple. At some point it will make more sense to restart the project from scratch. You can also try to contact me by e-mail if you have a particular question about the code in the CVS tree, but my memory on it is fading, too. Nothing remains the same.


HFS stands for the Hierarchical File System. HFS and HFS Plus are the filesystem formats of Apple MacOS. While the older one, HFS, may look rather limited today, HFS Plus includes most of the capabilities one can find in UFS or Berkeley FFS: long file names, hard and soft links, special nodes, owner and group information, access permissions.

Additionally, both HFS and HFS Plus have a number of interesting features not found in UFS:

Apple has recently released the original HFS kernel and userland code (incl. HFS Plus) under the Apple Public Source License [APSL] as a part of Darwin, which created a nice opportunity to port it to FreeBSD.

HFS and HFS Plus in FreeBSD may be of particular value to parties interested in sharing filesystem resources over a network from FreeBSD to MacOS, because there will be no need to emulate HFS-specific features unlike in the case of FFS backing store.

Henceforth the term "HFS" will cover both HFS and HFS Plus unless explicitly specified otherwise. To avoid misreading, the old HFS format will be denoted as "plain HFS."

The term "port" used throughout this document means only that the HFS code has been ported from Darwin to FreeBSD; it has nothing to do with FreeBSD ports and packages (yet.)

About This Port

This port is based on the Darwin source code. It's legal to use or develop it as long as the APSL terms are kept.

This port should be considered highly experimental and therefore used with caution. Neither Apple nor the maintainer of this port will take responsibility for data loss or damage that might result from using this piece of software.

Port Components

This port consists of the following functional parts:


Via HTTP from this site:

version 01
2003-Mar-22: The first public version.
version 02
2003-Jun-23: Updated from Darwin 6.6 (MacOS 10.2.6.)
version 03
2003-Aug-12: Updated with respect to recent changes in FreeBSD-CURRENT. If you follow -CURRENT actively, you'll need this version. It contains no other improvements over the previous one.
version 03 patchlevel 1
2004-Feb-12: FreeBSD-CURRENT has changed enough to prevent earlier versions from building. This one will build successfully in FreeBSD 5.2-RELEASE or newer. Thanks to Zack Hobson, Nik Clayton, Brian Feldman, and Murata Shuuichirou for sending me relevant patches, and to all the people who kept reminding me about this project :-)
version 03 patchlevel 2
2004-Aug-30: This distribution is for FreeBSD 5.3-RELEASE.

Installation and Usage


Your system should be at least as new as 5.0-RELEASE.

To use MacOS-formatted disks, you will need FreeBSD-CURRENT as fresh as of the 24th of February, 2003 (5.1-RELEASE will do); otherwise this port's usability will be limited to HFS volume images and volumes created within IBM PC (MBR) partitions. To enable support of the MacOS disk format on architectures other that PowerPC, you will need to rebuild your kernel with the option GEOM_APPLE. This option is always enabled on the PowerPC architecture. In -CURRENT, it is also available as a loadable module called geom_apple since the 31st of May, 2003.

The kernel source must be installed at /usr/src/sys.

The source code of mount(8) must be installed at /usr/src/sbin/mount.

Building and Installing

	# tar xzf hfs-freebsd-xx.tar.gz
	# cd hfs-freebsd-xx
	# make
	# make install


	# mount -t hfs /dev/da0s3 /mnt


The GEOM_APPLE module will allocate the first slice of a MacOS-formatted disk to the partition map itself since the latter is self-contained. The first of conventional partitions will appear at slice 2. That partition may contain drivers or auxiliary data instead of a disk volume; GEOM_APPLE can't distinguish between them yet. You may have to look at the beginning of a partition with hexdump(1) to tell if it's an HFS volume—a 'BD' or 'H+' signature must appear at offset 0x400. On the other hand, it's all right to try to mount an obscure partition as an HFS volume; the driver will simply refuse it if it's not HFS.

Practical Applications

Managing your iPod from FreeBSD

If you have an iPod formatted for Mac, you can access its files from FreeBSD as well. Eirik Oeverby <ltning at anduin dot net> reports that it's possible to connect an iPod to a FreeBSD host through FireWire. Of course, you'll need to load the FireWire driver in advance.

The entire disk of your iPod will be accessible as /dev/daX, where X is a number assigned to this new device upon plugging it. The GEOM_APPLE module will further split the disk into /dev/daXs1, a partition map partition (yes, it's self-contained); /dev/daXs2, a firmware partition; and /dev/daXs3, an HFS Plus volume partition. Obviously, you should mount the latter.

Eirik also reports that he had been unable to mount the HFS volume of his iPod until he took his chance with repairing it using the port of fsck_hfs. Beware of iPod firmware bugs silently eating the file system!

Note that you'll need software to manage the iTunes database on your iPod, or else audio files uploaded won't show up in your iPod playlist. There's a number of open-source projects around dedicated to that. Look for myPod, gtkPod, or whatever.


Thank Apple for taking the open-source way.

This work was initially sponsored by the KDS Ratmir company.

The original location of this page is here.

$Id: index.html,v 2004/08/31 07:00:46 yar Exp $