Source

Contents

  • Introduction
  • Installation
  • Configuring Netatalk
  • Configuring Avahi
  • Configuring your Mac


Introduction

There are a number of ways to get Time Machine to backup to a Linux, and while theoretically it is possible to use a Samba share, the best way to do it is to setup Linux (in this case Ubuntu 9.04) to work as a Mac server to OS X. 

This guide will walk you through, step-by-step, to install the open-source implementation of the Apple Filing Protocol (AFP), which is what allows Macs (or in this case other UNIX-like OS) to share services across a network.

This guide uses the Command-line based text editor nano. If you would prefer to use another editor (such as vim) simply replace nano with your chosen editor in the given commands. Alternatively, if you are running the Desktop version of Ubuntu 9.04, it might be easiest to replace nano with gedit, a graphical based text editor.

After you are finished editing each file with nano, you must save your changes with Control+X. You must use the control key, even if you are remotely editing (via ssh or similar service) on a Mac.

It is recommended that before following the setup in the rest of the guide, that you run these commands to ensure that your Ubuntu installation is up-to-date. NOTE: Everything after the ‘#’ is a comment, and does not need to be copied into the Terminal.

CODE: SELECT ALL
sudo apt-get update #Refreshes Ubuntu Repositories
sudo apt-get upgrade #Downloads and installs new updates
sudo apt-get autoclean #Deletes unneeded installation files



Installation

Installing AFP on Ubuntu (or any other UNIX-like OS) requires one basic open-source package (plus other prerequisite packages):

  • Netatalk - contains the actual implementation of AFP
  • Avahi – broadcasts server’s presence across LAN to allow OS X to access them


These commands to install the proper packages (requires internet connection):

CODE: SELECT ALL
sudo apt-get install netatalk avahi-daemon



Configuring Netatalk

Once all of the needed packages are installed, you will need to configure Netatalk to work properly. Run:

CODE: SELECT ALL
sudo nano /etc/default/netatalk



Scroll to the bottom of the file and under the “# Set which aemons to run (papd is dependent upon atalkd):” change your configuration to match the following:

CODE: SELECT ALL
ATALKD_RUN=no
PAPD_RUN=no
CNID_METAD_RUN=yes
AFPD_RUN=yes
TIMELORD_RUN=no
A2BOOT_RUN=no



These commands will prevent unneeded services from starting at boot, causing your machine to boot much quicker.

Next open afpd.conf,

CODE: SELECT ALL
sudo nano /etc/netatalk/afpd.conf



and append the following line to the end of the file:

CODE: SELECT ALL
- -transall -uamlist uams_randnum.so,uams_dhx2.so -nosavepassword -advertise_ssh



Finally, you will need to tell Netatalk what to share as a Volume. Open up the AppleVolumes.default file with

CODE: SELECT ALL
sudo nano /etc/netatalk/AppleVolumes.default



Comment out all lines (put a '#' at the beginning of the line) and add this to the end of the file (if the volume you want to share is /media/backup and the username you want to use with Time Machine is gries818):

CODE: SELECT ALL
/media/backup Backup allow:gries818 cnidscheme:dbd options:tm



Additional lines can be added to give access to different folders on the Ubuntu machine.

Restart netatalk with:

CODE: SELECT ALL
sudo /etc/init.d/netatalk restart



Configuring Avahi

Netatalk can be used without any further configuration, but in order to get the server in the "Shared" section in the Finder window, you need to configure Avahi (which is basically an open implementation of Apple's Bonjour service).

First, edit nsswitch.conf with

CODE: SELECT ALL
sudo nano /etc/nsswitch.conf



and add mdns to the end of the line that starts with "hosts:".

Next, will need to create a new file for Avahi so it knows what services to broadcasts to the Macs on your network. 

CODE: SELECT ALL
sudo nano /etc/avahi/services/afpd.service



And copy this xml data into the file:

CODE: SELECT ALL
<?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=MacPro</txt-record>
</service>
</service-group>



This will make your server display itself as a MacPro, but you can make it display as any type of a Mac you want by substituting the model=MacPro with the desired model:

  • iMac
  • MacPro
  • MacBook
  • MacBookPro
  • MacBookAir
  • PowerBook
  • PowerMac
  • Macmini
  • Xserve
  • AirPort


Now, simply restart Avahi to make Finder aware of the new services available on your Ubuntu machine.

CODE: SELECT ALL
sudo service avahi-daemon restart



Configuring your Mac

Finally, to use TimeMachine with your Ubuntu setup you need to override the default TimeMachine settings on your Mac. Open up the Terminal (/Applications/Utilities/Terminal.app) and type:

CODE: SELECT ALL
defaults write com.apple.systempreferences TMShowUnsupportedNetworkVolumes 1



Your new Shared Volume will now available in the TimeMachine disk selection. 

Conclusion

If you have any problems with this tutorial be sure to ask... not every setup will yield the same results. Additionally, this should work with any Linux OS, provide you make adjustments for the different package managers (apt is Ubuntu's package manager).