File Sharing from Linux to OS X: A Quick Guide

9 June 2004 • article | Mac • PermaLink

All my home machines are Macs now, except for the file server in my basement, which is a Debian box.

Previously, I had Samba installed on it so I could store some files from my other machines remotely. But using Windows file sharing between Macs and Linux just seemed wrong.

Here’s a very quick guide on how to get Apple file-sharing going on your Debian box, and how to make that server show up automatically in your Mac’s Finder. These instructions are specific to Debian (i.e. packages, paths, etc.), but should be easily modified to work on other flavours of Linux.

Disclaimer

This guide was written mostly from memory, and with a get-it-up-now-and-edit-it-later mentality. If you notice anything wrong with the instructions, or something isn’t working, let me know and I’ll edit the guide where appropriate.

Install the Required Packages

On your Debian box, you will need to install some packages. First, however you will need to add the following line to your /etc/apt/sources.list file:

deb http://interreality.org/software/debian unstable main

More on that later.

Now, run apt-get update and then install the following packages (and their dependencies):

  • netatalk
  • howl-tools
  • mdnsresponder

Netatalk is “a freely-available, kernel level implementation of the AppleTalk Protocol Suite, originally for BSD-derived systems.” It will provide the file-sharing functionality (like Samba did).

Howl is “a cross-platform implementation of Zeroconf networking.” It will allow your Mac to automatically discover the Netatalk file server. Howl isn’t part of the main Debian package system, which is why you needed to add that extra line to the sources file.

If asked, just accept the default configuration options for now.

Configure Netatalk

First, we need to enable AFP-over-TCP, which is how Apple file sharing works in OS X. Netatalk comes with some other daemons which we don’t really need: ATALKD to handle Appletalk (required for OS 9 and earlier, I think), TIMELORD, to serve time, a la ntpdate, and PAPD: an Appletalk printer daemon. Like I said, my Mac experience started with Jaguar, so I don’t really any of those. To disable them, you need to edit /etc/default/netatalk. Make sure the following options are set:

ATALKD_RUN=no PAPD_RUN=no AFPD_RUN=yes TIMELORD_RUN=no

We’re basically turning everything off except the AFP daemon.

Second, we need to specify the location of our shared directories. These are defined in /etc/netatalk/AppleVolumes.default. There are lots of configuration options in there. The default set up has this configuration line:

~/ "Home Directory"

This will share the home directory of whatever user logs in.

Note: because of the way Netatalk handles filename conversion between Mac and Linux, on my system I set up a separate directory for shared files, and another for the database and other control files Netatalk uses. The end result is my home directory isn’t as cluttered. My AppleVolumes.default looks like this (all one line):

var/local/shares/cmv/ "AFP Share" allow:cmv <font class="lf">¬</font> dbpath:/var/local/shares-db/cmv options:noadouble,nohex

Looking at the manpage for AppleVolumes.default describes all those options.

Finally, do a /etc/init.d/netatalk restart to get it all running.

Take a Quick Reality Check

At this point, you should have a working AFP file server. You can test by trying Finder › Go › Connect to server… and entering afp://servername/ as the server address.

If that doesn’t work, then something is wrong with your Netatalk configuration (check the logs), or maybe your internal network isn’t allowing the traffic. Make sure TCP ports 548 and 427, and UDP ports 548 and 5353 are open between your file server and the Mac (UDP 5353 is actually for Rendezvous/Zeroconf, which we’ll configure next).

Configure Howl

Now, all that’s left is to set up Rendezvous (a.k.a. Zeroconf) on the file server, so your AFP share is automatically displayed in the Finder.

Create the file /etc/howl/mDNSResponder.conf (if it doesn’t exist) with the following line:

MyServer _afpovertcp._tcp local. 548

Feel free to change “MyServer” to something more descriptive; that is the text that will appear in the Finder.

What this is saying is that Howl should publish via Rendezvous the service called “MyServer”, which uses the “afpovertcp” service over TCP, on the local netblock, and that this service runs on port 548. If you have sshd running on the same machine, you can add this line too:

MyServer _ssh._tcp local. 22

Do a /etc/init.d/mdnsresponder restart to get it all running.

To test it, try running mDNSBrowse _afpovertcp._tcp from the command line on the file server. You should see something like:

browse reply: Add Service MyServer _afpovertcp._tcp. local. resolve reply: MyServer _afpovertcp._tcp. local. 192.168.0.1 548

Final Test

On your Mac, go to Finder › Go › Network and click on the Local folder. Voilà, you should see an icon for your Debian file server. If you added the ssh configuration line above, you can also launch Terminal.app and try File › Connect to server…, then select the Secure Shell (ssh) service. Your Debian machine should show up in the list of servers.

Comments

  1. Thanks for this – it’s really interesting that I decided (instead of buying a firewire enclosure or two) I’d set up a linux server to use my extra hard drives. I did not want to go the samba route but was not sure how I was going to get around it. Then I read your blog and here is the solution :) Great stuff!!!
    Kent
    14 June 2004, 09:16 • PermaLink
  2. I did something similar on FreeBSD a few years back for a overseas publisher who has mac laptops for staff on assignment down in South Africa to basically allow them to upload their photographs to a shared area on the FreeBSD server using appletalk and then the publisher would ftp and grab the files they wanted.

    Under FreeBSD you have to also recompile the kernel.

    Don’t remember there being a app like howl when I did the implementation but howl sounds cool for the next time I implement a similar setup.
    Jacques
    19 June 2004, 09:03 • PermaLink
  3. This information was very helpfull. I can now try this solution for transferring my data from the Mac to my PC.
    James
    9 July 2004, 03:15 • PermaLink
  4. I have ATALKD and AFPD running on Mandrake 10. And my shares are displayed in Finder without HOWL.
    Mikhail
    21 July 2004, 02:14 • PermaLink
  5. At the moment, the Interreality source is only providing some unrelated 3D packages, no zeroconf/howl stuff.
    Looge
    26 July 2004, 15:03 • PermaLink
  6. Looge:

    Interreality provides the Debian packages for Howl here.

    If you want the full source (to compile on another platform, for instance), you should grab it directly from Porch Dog Software here.
    Colin
    27 July 2004, 16:02 • PermaLink
  7. Thanks for this info, I wanted to use my P4 box
    as a File Server( running Suse 9.1) for my Macs.
    I was gonna try to use NFS or Samba but after reading your blog, I’m gonna use netatalk.

    Internet is filled with Windows and Linux networking how-to, but very little on Linux and OS X.
    hitsuzen
    28 September 2004, 02:31 • PermaLink
  8. For you Red Hat users out there, note that the Fedora distributions include a netatalk RPM. I hunted everywhere for a binary RPM before realizing this.
    Trevor Harmon
    11 January 2005, 21:27 • PermaLink
  9. I followed this wonderful guide, but I cannot seem to get the folders that OS X creates hidden, like “Network Trash Folder” and such. Anyone find out how to get rid of those? (I’m doing this on Arch Linux, rather than Debian, but everything else is basically the same).
    link
    23 January 2005, 18:11 • PermaLink
  10. Trevor, note that Fedora includes Netatalk 1.x and I haven’t been able to find an rpm for version 2. Netatalk 2 has a LOT of improvements and is probably worth considering installing from binary / source.
    Jimmy
    13 February 2005, 02:14 • PermaLink
  11. There are now newer Howl packages in the main debian repository, and I might stop providing debs for that old version at any time, if it’s even still available.

    The newer howl packages in the main Debian repository are called mdnsresponder, and howl-utils instead of howl-tools.

    Reed
    Reed
    30 March 2005, 15:22 • PermaLink
  12. Hi there, I did the netatalk installation on a Gentoo GNU/Linux machine and works great! I have a problem with HOWL though here is the error I get:

    l-(root)
    2.6.11-gentoo-r9)-(20 June 2005 – 22:46)-(pts/0)
    mq-(/etc/conf.d)-> mDNSBrowse _afpovertcp._tcp
    [assert] error: 111 (Connection refused)
    [assert] where: “socket.c”, “sw_socket_tcp_connect”, line: 720
    Mario
    20 June 2005, 11:38 • PermaLink
  13. same problem on gentoo. but then
    realized that /etc/init.d/mDNSResponder wasn’t really starting the server. Manually starting /usr/bin/mDNSResponder fixes it.
    francisco
    1 October 2005, 15:07 • PermaLink
  14. i believe the newest version of Netatalk (2.0.3) allows for long filenames

    Steve
    9 December 2005, 16:00 • PermaLink
  15. Yes, Netatalk 2 fully implements AFP 3.1 which includes long file names and large files support.

    Jimmy
    7 January 2006, 21:28 • PermaLink
  16. Thank a heap for this. I tried this last summer, and I was having issues with Fedora Core. However, I’ve got it up and running in an hour in Debian. It’s great – I’m using it to help speed up maintence on my mail, DNS, VPN and file servers.

    Thanks again!

    PlaidRabbit
    23 January 2006, 15:37 • PermaLink
  17. This is pretty cool. How does AFP handle the resource fork issue when you copy or rsync a file over to the linux server. Thanks!

    Goglamosh
    23 January 2006, 22:15 • PermaLink
  18. Fantastic post, many thanks from buy auto parts

    Anonymous
    27 January 2011, 15:09 • PermaLink