Barry Price

Just another Perl Ruby hacker, ensconced in Asia

Apple File Server on Ubuntu 12.04

| Comments

As with the last post, this is another quick write-up of how to get Ubuntu 12.04 on my home server to play nicely.

Specifically, this one deals with running a file server accessible from my desktop, which is a Mac running OSX Lion.

Yes, we could use Samba, but I don’t have any Windows machines, and I like keeping things simple. Using netatalk and avahi removes all that Windows-related unpleasantness, and also seems more efficient – files certainly seem to transfer much faster than they did using Samba.

1
sudo apt-get install netatalk avahi-daemon

That was easy.

There are, of course, a few tweaks:

1
sudo editor /etc/netatalk/afpd.conf

Add this line to the bottom of that file:

1
- -tcp -noddp -uamlist uams_dhx.so,uams_dhx2_passwd.so -nosavepassword -setuplog "default log_info /var/log/afpd.log"

Next, define the actual shares:

1
sudo editor /etc/netatalk/AppleVolumes.default

Scroll to the bottom of the file, comment out the default home directory share, and replace it with this one, plus extra lines for any other directories you want to share:

1
2
3
4
5
6
7
8
9
10
# The line below sets some DEFAULT, starting with Netatalk 2.1.
:DEFAULT: options:upriv,usedots

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

# End of File

~/           "Home Directory" cnidscheme:dbd
/opt/storage "Storage"        cnidscheme:dbd

Finally, restart the services:

1
2
sudo /etc/init.d/netatalk restart
sudo restart avahi-daemon

As Paul pointed out in a comment, if you’re running a firewall you’ll need to allow connections on TCP port 548. Assuming you’re using ufw (and if you’re not, you should be – it’s great), it’s a simple matter of:

1
sudo ufw allow 548

Or if you want to be more selective about who gets access, you can restrict it by IP:

1
sudo ufw allow proto tcp from 192.168.1.8 to 192.168.1.4 port 548

In the above example, my Ubuntu server is at 192.168.1.4, and my Mac is at 192.168.1.8. Or if you use DHCP, allow the whole range or indeed the whole class C:

1
sudo ufw allow proto tcp from 192.168.1.0/24 to 192.168.1.4 port 548

Now if you open a Finder window on your Mac, you should see the server show up under the Shared section – click on it, log in using your Ubuntu username/password, and viola – there are your shares.

Comments