Let me just start out by saying that I am a complete newbie as far as Linux goes. With that said – this tutorial does involve using the Terminal.

Goal: I have been wanting to configure a file server for my Windows 7, Windows XP, and Mac OS X Lion home network environment. I got tired of trying to make Windows shared folders to show up in Finder and visa versa.

Just so happens my parents old eMachines decided to die a few months back, naturally I took it home to see what I can salvage from it. Turned out all it needed was a new power supply. $28 bucks later and after I slapped a spare 320GB Hard Drive in it, I had a perfect file server. Of course I put Ubuntu on it because that’s what all the cool kids do. So my file sharing to Mac OS X began…

NOTE: In Mac OS X Mavericks, Apple has shifted from using AFP in favor of SMB2. I will update this post once I figure out how to get Ubuntu and Mac to talk to each other. In the mean time please hold off on configuring this if you are using Mavericks. Any suggestion are welcome in the comments below.

 

1. Install Netatalk

Netatalk is the Open Source implementation of AFP, Apple file Sharing Protocol. Simply open Ubuntu Software Center and search “netatalk”.

Configure Netatalk

Open up Terminal. Run the following command:

sudo gedit /etc/default/netatalk

The sudo command is the Windows equivalent of “Run as Administrator”. It gives you elevated privileges, which is what you will need to modify system files. The next command gedit opens Ubuntu’s native text editor. The next command /etc/default/netatalk just specifies the file path.

Edit the netatalk file to match the code below

ATALKD_RUN=no
PAPD_RUN=no
CNID_METAD_RUN=yes
AFPD_RUN=yes
TIMELORD_RUN=no
A2BOOT_RUN=no

Then close and save the document. Next we have to edit the main config file for AFP sharing called afpd.conf:

sudo gedit /etc/netatalk/afpd.conf

Scroll down to the very bottom and add this to the bottom (If there is already a line there, replace it with this one):

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

Save and close the document.

2. Install Avahi

Avahi advertises all defined services across your network just like Bonjour does. It will let your Mac automatically discover your Ubuntu box in Finder.

sudo apt-get install avahi-daemon

Now we have to edit the nsswitch.conf file:

sudo gedit /etc/nsswitch.conf

All you have to do here is add “mdns” at the end of the line that starts with “hosts:”. It should look like this:

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

Save and close the document.

Configure Avahi

Now we can tell Avahi to behave like Bonjour and advertise certain services. In our case we just want to advertise AFP sharing. A simple XML file can accomplish this. Run the following command:

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

A new document should open in gedit. Now paste the following into that new document and save the file:


<?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>

Restart Avahi daemon

sudo /etc/init.d/avahi-daemon restart

 

That’s it! You should now see your Ubuntu box show up in Finder. Beautiful.

Tagged with:
 

16 Responses to Make Ubuntu behave like a Mac Server

  1. Tom says:

    Thanks – this worked great on Precise 12.04.

  2. Doug J says:

    I tried this and it shows up in the side bar but it won’t let me connect, it always says there is a problems connecting. I guess it is a version problem, this seems to have been written a while ago and i’m running the latest version of Mountain Lion.

  3. Reto says:

    Like Doug J: There was a problem connecting to the server “blaukreis”.

    Server: Ubuntu 12.04
    Client Mac OS X 10.8.2

  4. Tom says:

    “sudo gedit” should be “gksu gedit” or “gksudo gedit” – never run a graphical application as sudo.

  5. James says:

    Thanks for the tip!

  6. […] I thought it’d be worth sharing this post as it’s something that I’m actually in the process of doing. Unless requested I won’t go through this tutorial, but I’d just like to draw your attention to it because it’s really helpful. Click. […]

  7. Andy says:

    I can’t find netatalk in the Ubuntu Software Center. Do I need to add an specific repo?

  8. James says:

    Try running this command in Terminal:

    sudo apt-get install netatalk

  9. Andy says:

    Heya, thanks for replying, I managed to install everything now and I was able to connect to my file server with a Mac once. But after restarting the server, OS X tells me that:

    “The version of the server you are trying to connect to is not supported. Please contact your system administrator to resolve the problem.”

    I didn’t do any updates or anything – as soon as I restarted the server OS X started to say this. Any ideas? I will greatly appreciate it.

    Thanks! And great tutorial too!

  10. James says:

    Are you using Mac OS X Mavericks or Mountain Lion to connect? There is a chance some of the Ubuntu software needs updating. Try running this:

    sudo apt-get update

    then…

    sudo apt-get upgrade

    All this does it check the repositories for updates and then the second command installs the updates. After it’s done you may want to double check your Avahi and Netatalk configurations.

  11. Andy says:

    I’m using Mavericks.

    It looks like Apple is ditching AFP in favor of SMB2. Maybe it has something to do with it as updating and upgrading with the commands didn’t work.

  12. James says:

    Bummer! I guess I need to go back to the drawing board and figure out how to make use of AFP and SMB2. Thanks for catching this, I’ll update the post.

  13. Andy says:

    Anytime mate! I’ll be trying to get it to work myself and I’ll let you know if I figure it out. Will stay tuned in case you do it first, haha.

  14. […] protocol was, much less that it was being deprecated. When I first set the file server up, I used this tutorial to make Ubuntu announce and interact with OS X via AFP. I had no problems following that tutorial, […]

  15. John says:

    Dude! this was awesome. Thanks!

  16. Topcat says:

    So simple, thanks a bunch!

Leave a Reply

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