Mount a HFS+ formatted drive on your Raspberry Pi

Install the necessary packets on your Raspberry Pi:

sudo apt-get install hfsplus hfsutils hfsprogs

The packet hfsplus “consists of a library and a set of tools that allow access to HFS+ volumes”. The packet hfsutils “contains several command-line utilities for reading and writing Macintosh HFS-formatted media”. The packet hfsprogs provides “mkfs and fsck for HFS and HFS+ file systems”.

Plug your drive into the Raspberry Pi. To find out the location of the drive in your system, start the parted tool with

sudo parted

, afterwards type the command

print all

to list all your drives and partitions, look for an entry that reminds you of the model and size of your drive:

[...]
Model: WD My Passport 25EA (scsi)
Disk /dev/sdb: 4001GB
Sector size (logical/physical): 512B/4096B
Partition Table: gpt
Disk Flags:

Number  Start   End     Size    File system  Name                  Flags
 1      20.5kB  210MB   210MB   fat32        EFI System Partition  boot, esp
 2      210MB   4001GB  4000GB  hfs+
[...]

From this output, we now know that our disk resides in /dev/sdb and the usable partition has the number 2. We also can verify that the file system really is HFS+. Quit the parted tool with quit.

Because /dev/sdb could change the next time we plug in the drive, we need to know the UUID of our drive:

ls -l /dev/disk/by-uuid

resulting in an output similar to the following:

total 0
lrwxrwxrwx 1 root root 10 Dec 28 22:09 4d741220-336d-30ab-a66c-f439cd66d71f -> ../../sdb2
lrwxrwxrwx 1 root root 10 Dec 28 22:09 67E3-17ED -> ../../sdb1
[...]
lrwxrwxrwx 1 root root 15 Dec 23 07:25 e9646bf0-ef1f-4e8b-983b-c9f97f60e931 -> ../../mmcblk0p2
lrwxrwxrwx 1 root root 15 Dec 23 07:25 FBD8-71DF -> ../../mmcblk0p1

Look for the line ending with -> ../../sdb2 and copy the long number at the beginning, in our case: 4d741220-336d-30ab-a66c-f439cd66d71f, this is the UUID of our drive.

Create a mount point:

sudo mkdir /media/tm

Change the owner of the folder:

sudo chown -R pi:pi /media/tm

Open the fstab file:

sudo nano /etc/fstab

Insert the following entry (you have to adapt it to your actual settings) in your fstab file:

UUID=4d741220-336d-30ab-a66c-f439cd66d71f /media/tm hfsplus defaults,force 0 0

the option defaults is a shortcut for the options rw,suid,dev,exec,auto,nouser,async. More on the different possible options here and here. The option force is needed to really create a writeable filesystem. It seems that this has something to do with HFS+ disks being journaled, see here for more information. The two 0 at the end specify that there should be no (dump)-backup and no file system checking.

Close and save your fstab file and mount everything:

sudo mount -a

Check whether your drive really is mounted:

df -h

(the option -h displays output in human readable format) producing an output similar to the following:

Filesystem      Size  Used Avail Use% Mounted on
/dev/root        15G  2.6G   12G  19% /
devtmpfs        484M     0  484M   0% /dev
tmpfs           489M     0  489M   0% /dev/shm
tmpfs           489M   13M  476M   3% /run
tmpfs           5.0M  4.0K  5.0M   1% /run/lock
tmpfs           489M     0  489M   0% /sys/fs/cgroup
/dev/mmcblk0p1   44M   22M   22M  51% /boot
[...]
/dev/sdb2       3.7T   65G  3.6T   2% /media/tm
tmpfs            98M     0   98M   0% /run/user/1000

As Alternative, you can use the following command:

sudo blkid -o list -w /dev/null

which will produce an output like this:

device           fs_type  label     mount point          UUID
----------------------------------------------------------------------------------------------
/dev/mmcblk0p1   vfat     boot      /boot                FBD8-71DF
/dev/mmcblk0p2   ext4     rootfs    /                    e9646bf0-ef1f-4e8b-983b-c9f97f60e931
/dev/mmcblk0                        (in use)
[...]
/dev/sdb1        vfat     EFI       (not mounted)        67E3-17ED
/dev/sdb2        hfsplus  himpi_4t  /media/tm            4d741220-336d-30ab-a66c-f439cd66d71f

Check whether volume works properly by executing:

sudo fsck.hfsplus -f /dev/sdb2

The option -f is needed if the volume is journaled. Output should look like:

** /dev/sdb2
** Checking HFS Plus volume.
** Checking Extents Overflow file.
** Checking Catalog file.
** Checking Catalog hierarchy.
** Checking Extended Attributes file.
** Checking volume bitmap.
** Checking volume information.
** The volume himpi_4t appears to be OK.

If you want to unmount the volume, use

sudo umount /media/tm