How to share folders on the Pi using Apple Filing Protocol (AFP)


Apple Filing Protocol is Apple's proprietary network protocol for distributing files over the network. This is Apple's replacement for the Server Message Block (SMB) and Network File System (NFS) protocols.

Following this guide, you will be able to share any folder on your Raspberry Pi using AFP and easily connect to them from your Mac OS X device.

All of this is possible with the Netatalk software. The software implements the AFP protocol at the server level, allowing the Raspberry Pi to distribute files through it.

Setting up AFP on Raspberry Pi

1. Now, before you can set up AFP on your Raspberry Pi, you must ensure that the operating system is up to date.

To make sure everything is up to date, run the two commands below.

 
sudo apt update
 sudo apt upgrade

2. With the now updated Raspberry Pi, you can now go ahead and install the package that will take care of everything. The package you are installing is called Netatalk. Open source Netatalk is used to implement the free Apple Filing Protocol (AFP).

Install the Netatalk application onto the Raspberry Pi by running the following command.

 
sudo apt install netatalk

3. After installing Netatalk software, now you have to continue configuring it to share different folders.

First, let's look at how to add folders for sharing. To do this, you have to modify the afp.conf file by running the command below.

 
sudo nano /etc/netatalk/afp.conf

4. In this file, add the following text at the end.

Add home folders

 
[Homes]
 basedir regex = /home

This block identifies the home directories. This block will allow any connected users to access their respective home directories.

Locate "basedir regex" so the Netatalk software knows where to find the user's home directory.

If you want to lock users to a specific directory in their main path, you can add the following option. With <foldername> is the name of that folder.

 
[Homes]
 basedir regex = /home
 path = <foldername>

Add custom folders

 
[My AFP Share Name]
 path = /path/to/directory

Using something like above, you can share any folder you want.

In square brackets ( [] ) specifying when to start sharing is the name given to the sharing.

The option "path =" is the path to the folder you want to share over the AFP protocol.

Create a share as an Apple Time Machine

 
[My AFP Share Name]
 path = /path/to/directory
 time machine = true

You can specify any sharing process as a shareable time machine, by simply adding the option "time machine = true" below.

Share read-only

 
[My AFP Share Name]
 path = /path/to/directory
 read only = true

If you want the share to be read only, all you have to do is add "read only = true" to it. This option is useful for sharing, such as sharing media library.

Set up a guest account

 
[Global]
 guest account = pi

You can specify the guest account to use for connections by setting "guest account =" in the heading "[Global]." By default, this is set to "nobody".

More information on available options can be found by visiting the Netatalk configuration documentation at.

 
http://netatalk.sourceforge.net/3.1/htmldocs/afp.conf.5.html

5. When changes to the configuration are complete, you can go ahead and save the file by pressing CTRL + X then pressing Y , and then pressing ENTER.

6. Since you have made changes to the Netatalk configuration, it is necessary to restart the service so that it can use the new configuration.

Restart the service by running the following command.

 
sudo systemctl restart netatalk

7. Before connecting to the newly shared folders, you should retrieve the IP address assigned to the Raspberry Pi . Make sure you have an active network connection using either WiFi or an Ethernet cable . Write this IP down as you will need it to connect to the shared drive.

 
sudo hostname -I

Connect to Pi's AFP sharing process on Mac OS X

1. To connect to the AFP sharing process on Raspberry Pi, start by opening the Finder application available on Mac OS X.

Open the Finder app available on Mac OS XOpen the Finder app available on Mac OS X

2. Now go ahead and click “Go” on the toolbar at the top of the screen. Next, click on the option “Connect to Server…” .

Click the option "Connect to Server ..."Click the option "Connect to Server ..."

3. In this dialog box, you will need to enter the IP address of the Raspberry Pi after "afp: //".

For example, with the Raspberry Pi's IP address being “192.168.0.159” , you need to enter “afp: //192.168.0.159” in the input box. Once entered, click the "Connect" button to continue.

Enter the IP address of the Raspberry PiEnter the IP address of the Raspberry Pi

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

Since the article is only for the default user, for example use "pi" as the name and "raspberry" as the password. After entering the user to connect, go ahead and click the “Connect” button to continue.

Enter the username and password to connect to the Apple Filing Protocol serverEnter the username and password to connect to the Apple Filing Protocol server

5. After successfully logging in to the Raspberry Pi's AFP share, you will now be asked which volumes you want to mount.

This dialog box displays all the folders that you have set up earlier in the tutorial, each referenced by the name you put next to that share in the configuration file.

Select the volume you want to mount. Then click the OK button to continue.

Select the volume you want to mountSelect the volume you want to mount

6. Finally, you should be able to view your mounted shares to your Mac OS X device.

Below, the post has included a screenshot showing the networked drives in "Locations" in the sidebar. The example also shows shared volumes in the Finder application.

Shared volumes in the Finder applicationShared volumes in the Finder application

At this point, Apple Filing Protocol is running on your Raspberry Pi. You can also use a MAC OS X device to successfully connect to your shared folders via the AFP protocol.

See more:

How to connect the Raspberry Pi remotely to a Windows computer
How to change DNS server on Raspberry Pi
Turn your Raspberry Pi into a Mac or PC with Twister OS
How to set up MiniDLNA on a Raspberry Pi
How to install CentOS on a Raspberry Pi
Enable SPI on Raspberry Pi
How to set up and use ExpressVPN application for Raspberry Pi



Operate and exploit advertising by iCOMM Vietnam Media and Technology Joint Stock Company.
Adress: 99 Nguyen Tat Thanh, To 2, Khu 6, Thi tran Tan Phu, Tan Phu, Dong Nai.
Email: phuongtran2191@gmail.com | Tel: (+84) 984654960
Editor in chief: Tran Nha Phuong
Company: Lucie Guillot (Nha Phuong Tran)

Contact

INFORMATION RESEARCH LIMITAD
Responsible agency: Union of Science and High-Tech Production and Telecommunications (HTI)y
Copyright © 2022 iCOMM Tech JSC