Apple File Sharing (AFP) via FreeBSD

Liquid error: undefined method `login' for nil:NilClass : January 18th, 2006

So, I got a shiney new Mac Mini before Thanksgiving. Well, actually it was for my mom, but I ended up keeping it and buying her another. Longer story... In any case I love it, but it's a bit underpowered for heavy unit testing and other intense programming tasks. And I switched from a dual-screen Athlon 1800XP FreeBSD box, so I was feeling lagged for a bit. So with the beautiful Mac OS X in front of me there was only one thing left to do with the FreeBSD box... *Apple file sharing*. :-) I wanted to access files on the FreeBSD box from Finder, edit my Rails projects (on the FreeBSD box) using TextMate, and generally enjoy both the beauty of OSX and the horse-power of FreeBSD on faster hardware. h2. Installation I loosely followed the guide from: "http://viebrock.ca/article/22/file-sharing-from-linux-to-os-x-a-quick-guide":http://viebrock.ca/article/22/file-sharing-from-linux-to-os-x-a-quick-guide Of course that guide is for Debian, hence this post for FreeBSD users. Install from ports: * netatalk * howl h2. Enable the necessary services
Add the following to /etc/rc.conf:
netatalk_enable="YES"
afpd_enable="YES"
mdnsresponder_enable="YES"
mdnsresponder_flags="-f /usr/local/etc/mDNSResponder.conf
You may not need the last line. I have NO idea where FreeBSD howl's mDNSResponder looks for it's config file. I *much* prefer Debian here (for how it gives you reasonable default files that get you started). h2. Setup and start afpd # Rename /usr/local/etc/AppleVolumes.default.dist removing the ".dist" # Change the last line to read as follows:
~ options:usedot,noadouble,nohex
# /usr/local/etc/rc.d/netatalk.sh start The above configuration will allow things like subversion to work that use hidden "dot" files. h2. Test your setup You should now be able to do *Finder -> Go -> Connect to Server...* Connect to: afp://server_or_ip_address/ You should get a list of home directories to browse and mount. If not, you've done something wrong above. h2. Setup and start howl Next, we need to setup howl so that we can automagically find our FreeBSD box on the network. # Create /usr/local/etc/mDNSResponder.conf:
YourServer     _afpovertcp._tcp     local.     548
YourServer     _ssh._tcp     local.     22
# /usr/local/etc/rc.d/mdnsresponder.sh start YourServer is the name that will show up in Finder... you should also be able to use *Terminal -> File -> Connect to Server...* and such for SSH now... Have fun!

9 Responses to “Apple File Sharing (AFP) via FreeBSD”

  1. Alastair Says:
    Default howl config file is here: /usr/local/etc/howl/mDNSResponder.conf Also curious as to why you wouldn't just set up /etc/exports and use NFS instead of AFP?
  2. Josh Goebel Says:
    NFS has never worked well for me in the various situations I've tried it... I think I did consider that first but then said "forget it" and decided to get it to work all plug and play with my Mac. :-) It was worth it. I switched out my 10mbit hub (never needed more) for a 100mbit switch and it's plenty fast now.
  3. Jason Says:

    I stumbled on this looking for an alternative to NFS because of performance issues. This works great. With NFS I get ~4MB/s. With sftp I get ~9MB/s. With afp I now get ~16MB/s. It’s also great to see my server show up in the finder. Thanks for the instructions.

  4. Marte Says:

    I agree with Jason it works great, however my results are not as good as yours

  5. Nikolas Britton Says:

    Why are you using howl for this? Wouldn’t mDNSResponder (mdnsd) be more appropriate?

    Anyhow, Thanks… I can now do static mounts (i.e. /Network/Library) (via Netinfo Manager) with Mac OS X. And with the default netatalk config it’s already faster then SMB…

    nbrittons-mac-mini:/Volumes/AFP-Share nbritton$ dd if=/dev/zero of=testfile bs=1m count=1000 1000+0 records in 1000+0 records out 1048576000 bytes transferred in 16.523385 secs (63460120 bytes/sec) nbrittons-mac-mini:/Volumes/SMB-Share nbritton$ dd if=/dev/zero of=testfile bs=1m count=1000 1000+0 records in 1000+0 records out 1048576000 bytes transferred in 23.582741 secs (44463703 bytes/sec)

    60.5MB/s vs. 42.4MB/s, 18MB/s faster then SMB, although it’s a moot point because the mini’s stock hard drive taps out at around 27MB/s (seq. write) and 50MB/s (seq. read).

  6. Jon Says:

    Hey, just a minor typo above in the /etc/rc.conf Just missing a " mdnsresponder_flags="-f /usr/local/etc/mDNSResponder.conf"

    Thanks for this, works great..

  7. Peter Pistorius Says:

    The layout is broken on this article.

  8. J Says:

    Excellent tips, thank you! Worked like a charm (FreeBSD 7.0 64-bit, OS X 1.5)

  9. Simen G. Says:

    Thank you! Really needed this.

Leave a Reply

I am a human (check this)

Remember: escape your underscores \_ and indent code at least 4 spaces or incur the wrath of smartypants.