AFP in Ubuntu

Your ads will be inserted here by

Easy Plugin for AdSense.

Please go to the plugin admin page to
Paste your ad code OR
Suppress this ad slot.

This guide will walk you through installing and configuring AFP in Ubuntu. If everything goes well, your Apple computers will be able to connect (and backup with Time Machine) to the server without issue.

This article combines steps from other articles and updated to reflect the latest version of Netatalk (AFP), Mac OS X (Mountain Lion) and Ubuntu 12.04. These general steps can work for other distributions of Linux but have not yet been tested. In Ubuntu, there is no need to manually open ports in the firewall.

1.) Install Netatalk & Avahi

In the terminal:
sudo apt-get install netatalk
sudo apt-get install avahi-daemon
sudo apt-get install libnss-mdns

2.) Configure Netatalk

In the terminal:

sudo nano /etc/default/netatalk

Lines starting with a # are commented out which means the service/script will avoid it.
You can optionally remove the # before ATALK_NAME and name your AFP Server whatever you like. I named mine ‘vault’.

ATALK_NAME=vault

Make sure that these options are set and not commented out

CNID_METAD_RUN=yes
AFPD_RUN=yes

You can specify how many clients can connect to the server with “AFPD_MAX_CLIENTS“. Good if you want to limit the number of connections. Otherwise, leave this commented out for no limits.

Ctrl+O to save and Ctrl+X to quit Nano.

Next, let’s edit afpd.conf , the main configuration file for AFP/netatalk.

sudo nano /etc/netatalk/afpd.conf

Scroll all the way to the bottom and add this one line of code:

- -transall -uamlist uams_randnum.so,uams_dhx2_passwd.so -nosavepassword -advertise_ssh

Ctrl+O to save and Ctrl+X to quit Nano.

3. Users (optional)

You can configure your shares by adding additional users that are allowed to connect to it. All you will need to do is add a standard unix user. In the terminal:

sudo adduser bob

Where bob is the name of the user you would like to create.  You will then be prompted to enter the password for the new user you created and optional values for full name, room number, work phone, etc. You can skip these by pressing Enter through each one.

The primary user you created when you installed ubuntu will also work.

4. AFP Shared Volumes

Let’s further configure AFP to use certain volumes. In the terminal:

sudo nano /etc/netatalk/AppleVolumes.default

Scroll all the way to the bottom of the document. Take a note of the line that starts with:

~/ "$u"

This is a default share that shows the home folder to the user connected. You can optionally disable this by adding a # before it.

Your ads will be inserted here by

Easy Plugin for AdSense.

Please go to the plugin admin page to
Paste your ad code OR
Suppress this ad slot.

The syntax for adding a share is as followed:

/path/to/folder "Name of Volume" allow:mark,bob,user cnidscheme:dbd

For example, I have a mounted hard drive in my /media folder I will be using for Time Machine and another mounted hard drive for general storage. For a specific volume you would like to use for Time Machine, add options:tm at the end of the share.

/media/DiskA "Storage" allow:marcus,bob cnidscheme:dbd
/media/Backup "Backup" allow:marcus,bob,timemachine cnidscheme:dbd options:tm

Note: Starting with Netatalk 2.1, you do not need to add options:upriv,usedots as these are set up by default. This line should already be above where the Home directory share is.

Ctrl+O to save and Ctrl+X to quit Nano.

Great. Now we’ve set up AFP. Whenever you make changes to the files, you will need to restart AFP. You can do this with:

sudo service netatalk restart

5.) Configure Avahi

In the terminal:

sudo nano /etc/nsswitch.conf

Add “mdns” at the end of the “hosts:” line. It should look like this:

hosts:          files mdns4_minimal [NOTFOUND=return] dns mdns4 mdns

Ctrl+O to save and Ctrl+X to quit Nano.

Now we will be telling Avahi what to advertise on the network.

sudo nano /etc/avahi/services/afpd.service

Nano will show a blank document. This is normal as we will be creating a new file. Copy and paste this into the document:

<?xml version="1.0" standalone='no'?><!--*-nxml-*-->
<!DOCTYPE service-group SYSTEM "avahi-service.dtd">
<service-group>
<name replace-wildcards="yes">%h</name>
<service>
<type>_afpovertcp._tcp</type>
<port>548</port>
</service>
<service>
<type>_device-info._tcp</type>
<port>0</port>
<txt-record>model=Xserve</txt-record>
</service>
</service-group>

Ctrl+O to save and Ctrl+X to quit Nano.

Great. Now let’s restart the Avahi daemon.

sudo service avahi-daemon restart

You should be set! Your Mac should now see the server. Click on it and “connect as” with a user you specified when adding the volume.

Extra

Want to enable logging for debugging?

In the /etc/netatalk/afpd.conf file right below your addition, add:

-setuplog “default log_info /var/log/afpd.log”

Then just tail the last few lines of the file and try connecting.

tail -f /var/log/afpd.log

Leave a Reply

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload CAPTCHA.