In this Raspberry Pi Apple Filing Protocol tutorial, we will show you how you can share directories on your Pi using the Apple Filing Protocol (AFP).

Raspberry Pi AFP
The Apple Filing Protocol is Apple’s proprietary network protocol for delivering files over a network. It is Apple’s alternative to the Server Message Block (SMB) and Network File System (NFS) protocols.

By following this tutorial, you will be able to share any directories on your Raspberry Pi using AFP and easily connect to them from a device running the Mac OS X operating system.

All of this is made possible by the “Netatalk” software. This software implements the “AFP” protocol at a server level allowing your Raspberry Pi to serve files over it.

There are plenty of other NAS solutions that you can take advantage of so if this doesn’t take your fancy I highly suggest taking a look at them.

Equipment

Below is all the equipment that you will need for setting up the Apple Filing Protocol on your Raspberry Pi.

Recommended

Raspberry Pi

Micro SD Card (8GB+) if you’re using a Raspberry Pi 2, 3 or B+

Ethernet Cord or Wifi dongle

External Hard drive

Optional

Raspberry Pi Case

USB Keyboard

USB Mouse

Note: The USB ports on the Raspberry Pi might not be enough to power an external drive so you might need to invest in a powered USB hub.

Setting up Apple File Protocol (AFP) On your Raspberry Pi

1. Now before we can setup the Apple File Protocol (AFP) on your Raspberry Pi, we must first ensure that the operating system is up to date.

To ensure everything is up to date run the two commands below.

sudo apt-get update
sudo apt-get upgrade

2. With the Raspberry Pi now up to date, we can now proceed to install the package that will be handling everything.

The package that we are installing is called Netatalk. Netatalk is a free and open source implementation of the Apple Filing Protocol (AFP).

The Netatalk program acts as a file server that is capable of serving many Mac clients as it allows your Raspberry Pi to act as an AppleShare file server.

Install the Netatalk application to your Raspberry Pi by running the following command.

sudo apt-get install netatalk

3. As we have now installed the Netatalk software, we will immediately be able to access the user’s “home” directory as that is what is shared by default.

We will explain how to make a connection to the AFP share in our next section. For now, let’s look into how we can add additional folders for the Netatalk program to share.

To do this, we must modify the “AppleVolumes.default” file by running the command below.

sudo nano /etc/netatalk/AppleVolumes.default

4. Within this file, scroll down until you see the following line.

# By default all users have access to their home directories.
~/                      "Home Directory"

5. Below the previous lines, you can add additional directories that you want to be shared.

For example, if you want to add both the “media” and “mnt” drives to the share list, you can add them as we have shown below.

You need to add both the path to the directory and the name you want to be associated with it. The name that you specify for that directory will be displayed to the end user.

# By default all users have access to their home directories.
~/                      "Home Directory"
/media "Media"
/mnt "Mount"

6. Above the section that you found in the previous step, you should see the following line.

This line defines the default options that will be applied to all shares. We can modify this line to change the default behavior of our shares.

:DEFAULT: options:upriv,usedots

7. To the end of the “:DEFAULT:” line you can add additional options that you want to be enabled for every shared folder.

For example, if you wanted to allow users to read and write on each shared folder, we can add “rw” to the list (Make sure you add a comma).

You can also enable Apple Time Machine support for the shared folders by adding “tm” to the list.

For a more extensive list of options that you can enable, check out NetaTalk’s documentation.

Below we have an example of adding both read and write privileges as well as time machine support to the default list.

:DEFAULT: options:upriv,usedots,rw,tm

8. In addition to being able to apply options to all shared folders, you can also set options to specific folders.

For example, from our list of shares, if we wanted to make the “Media” share read-only, we can do that by adding options as shown below.

/media "Media" options:ro

9. With changes to the configuration complete, you can go ahead and save the file by pressing CTRL + X then Y followed by ENTER.

10. As we have made changes to Netatalk’s configuration, we need to restart the service so that it can utilize the new config.

We can restart the service by running the following command.

sudo systemctl restart netatalk

11. Before we connect to our newly shared folders, we should retrieve the IP address assigned to our Raspberry Pi.

Make sure you have an active network connection by using either WiFi or an Ethernet cable.

Write this IP down as we will need it for connecting to the shared drive.

sudo hostname -I

Connecting to your Pi’s AFP share on MAC OS X

1. To connect to your Raspberry Pi’s AFP share begin by opening the “Finder” application available on the Mac OS X operating system.

Opening Finder on Mac OS X

2. Now that we have opened up the “Finder” application go ahead and click “Go” (1.) in the toolbar at the top of the screen. Next, click the “Connect to Server…” (2.) option.

Mac OS X Connect to AFP protocol

3. Within this dialog, you will need to enter your Raspberry Pi’s IP address in front of the “afp://” protocol (1.).

For example, with our Raspberry Pi’s IP address being “192.168.0.159” we need to enter “afp://192.168.0.159” into the input box.

Once entered, click the “Connect” button (2.) to proceed.

Mac OS X Enter Raspberry Pi AFP Details

4. Upon connecting to your Raspberry Pi, you will be greeted by a dialog asking you to enter a username and password to connect to the Apple Filing Protocol server (1.).

As we are just using the default user, we only used “pi” as the name and “raspberry” as the password.

Once you have entered a user to connect with, go ahead and click the “Connect” button (2.) to proceed.

Mac OS X Enter AFP Share Login Details

5. Upon successfully logging into your Raspberry Pi’s AFP share you will now be asked what volumes that you want to mount.

This dialog will show all directories that you set up earlier in the tutorial, each referenced by the name you put next to that share in the config file.

Select the volumes that you want to be mounted (1.) Then click the “Ok” button to proceed.

Raspberry Pi AFP - Step 05 - Select Drives

6. Finally, you will now be able to see the shares that you mounted to your Mac OS X device.

Below we have included a screenshot showing the networked drives under “Locations” in the sidebar. We also show the shared volumes that are within the “Finder” application.

Raspberry Pi AFP - Step 06 - Drives in finder

At this point, you should now have the Apple Filing Protocol running on your Raspberry Pi. You should also be able to use a MAC OS X device to connect to your shared folders over the AFP protocol successfully.

If you have any feedback regarding this tutorial, then please don’t hesitate to leave a comment below.

Ultimate Books of Pi Bottom
Get projects delivered to your inbox weekly.