For
quite some time I use my Ubuntu machine as a file and backup server for
all Macs in my network which is perfectly accessible from the Finder in
Mac OS X. There are some instructions available in the web for this
task but all failed in my case so I wrote my own tutorial with all the
steps needed for it to work properly.
So here’s my little Tutorial for connecting Mac OS X Leopard with Ubuntu and using your Ubuntu machine as a backup volume for Time Machine but all steps can be reproduced on every Linux box and they work with Mac OS X 10.4 Tiger too. At the end of this tutorial you will have a server which shows up in the Finder sidebar and behaves just like a Mac server when accessing it from your Macs. To be perfectly integrated with Mac OS X we’re going to use Apple’s Filing Protocol (AFP) for network and file sharing.
Although this Tutorial involves using the Terminal in Ubuntu and looks a bit geeky it’s very easy even for beginners. I have tried to explain all steps and Terminal commands so you may learn a bit about the Terminal too. At the end of the article you can download my Server Displays icon pack quickly made by me with custom icons for a Mac, Ubuntu and Windows server.
Personally I use a fresh installation of Ubuntu 8.04 Hardy Heron Desktop version (32bit on one machine, 64bit on the other) and Mac OS X Leopard (10.5.3 and later) to connect to them. On my Ubuntu boxes there’s no other file sharing protocol like samba (Windows sharing) or NFS activated.
Update 12/07/2008:
Rumors are
Apple will add some undocumented AFP commands with the Mac OS X 10.5.6
update which therefor won’t be supported by the current Netatalk package
(and maybe never will). So be sure to check the latest comments on this
article when the 10.5.6 update is out to see if this rumor is true and
if there are problems caused by that.
Here are the steps involved in setting up your Ubuntu box as a Mac file server:
- Modify and install Netatalk (Open Source AFP implementation)
- Configure Netatalk
- Configure shared volumes (and Time Machine volume)
- Install Avahi (Open Source Bonjour implementation)
- Configure Avahi and advertise services
- Configure TimeMachine
- Conclusion, Problems and more informations
- Downloading and using the Server Display Icons
- Translations Of This Article
1. Modify and install Netatalk
Netatalk
is the Open Source implementation of AFP. Mac OS X requires encryption
to work properly but the standard package of netatalk provided in the
Ubuntu repositories doesn’t include this feature. So we have to build
our own netatalk package from the sources with the encryption feature
enabled.
First you have to enable the Source Code repositories via System > Administration > Software Sources under the Ubuntu Software tab. Check the Source Code Box, click Close and choose Reload in the next dialogue.
Update 09/28/2008: Alessandro has built a nice .deb package for i386 machines. Although written in italian you can follow the necessary code snippets for installing this package in his blog post. If the install package works for you just skip the following self compiling process and head over to the Configure Netatalk section.
Now fire up your Terminal under Applications > Accessories and execute the following lines (separately). You have to type Y for yes when Terminal asks you if it should continue:
sudo apt-get build-dep netatalk
sudo apt-get install cracklib2-dev fakeroot libssl-dev
sudo apt-get source netatalk
cd netatalk-2*
Now you have downloaded the source code of Netatalk to your home folder, installed some required packages for building Netatalk and changed the directory to the downloaded folder.
Next you have to build the Netatalk package with the encryption option enabled:
sudo DEB_BUILD_OPTIONS=ssl dpkg-buildpackage -rfakeroot
Depending on your hardware this may take a while but you can enjoy the geeky build output in your Terminal:
If everything went through without errors (except the signing warnings, can be ignored) you can install the recently created package:
sudo dpkg -i ~/netatalk_2*.deb
To stop Ubuntu from overwriting your custom Netatalk package you should set its state to hold. This will cause the Netatalk package being grayed out in the Software Update dialogue:
echo "netatalk hold" | sudo dpkg --set-selections
Now you have successfully build and installed your custom Netatalk package which now has support for encrypted logins. Now let’s configure the whole thing.
2. Configure Netatalk
First
you should deactivate services provided by Netatalk which are not
needed if you just want to use your Ubuntu box for file sharing. This
will speed up the response and startup time of Netatalk dramatically.
For instance Netatalk starts the old AppleTalk protocol by default which
is just needed for pre OS X systems. So we’re going to use the
graphical editor gedit for stopping unneeded services:
sudo gedit /etc/default/netatalk
gedit should pop up with the defined file loaded as superuser (needed for saving). Find the “#Set which daemons to run” part and replace the default values with these to enable just AFP and disable all unneeded services. Let the cnid_meta daemon run too and if you want to share your Linux connected printer with your Mac also enable the pap daemon (set to yes):
ATALKD_RUN=no
PAPD_RUN=no
CNID_METAD_RUN=yes
AFPD_RUN=yes
TIMELORD_RUN=no
A2BOOT_RUN=no
Here it’s very important to run the cnid_meta daemon because this service will handle all the metadata for us (namely the reosurce fork) which would get lost due to the fact that your Linux box isn’t formatted as Apple’s HFS+. If you’re interested what the other services could do: atalkd is the AppleTalk daemon (pre-OSX file sharing, old printing), timelord can make your Linux box a network time server and please don’t ask me for what a2boot is good for (If you know it, post it in the comments please / Kelly suggests it’s a netboot server for client Macs).
Press Ctrl + S to save the document or choose File > Save. Next we have to edit the main config file for AFP sharing called afpd.conf:
sudo gedit /etc/netatalk/afpd.conf
Scroll to the very bottom of the document and add this to the bottom (replace the whole line in case there’s already one). This is one line so be sure that there’s no line break in your afpd.conf file:
- -transall -uamlist uams_randnum.so,uams_dhx.so -nosavepassword -advertise_ssh
Press Ctrl + S to save the document or choose File > Save.
3. Configure shared Volumes
Now
we have to tell the afpd daemon what Volumes to share. This is defined
in the AppleVolumes.default file inside /etc/netatalk/. The following
line will open this file in the gedit editor with superuser privileges
(required for saving) where we can define our shared volumes:
sudo gedit /etc/netatalk/AppleVolumes.default
Scroll to the bottom of the document and define your Volume shares. By adding the following line you will share each users home directory with the user name as the Volume name. To make things more secure you can define all users who are allowed to connect to your Ubuntu box via AFP:
~/ "$u" allow:username1,username2 cnidscheme:cdb
Because we want to use the Ubuntu machine as a backup server for Time Machine you should define a second volume just for Time Machine. Create a new folder in your home directory first and name it TimeMachine (or anything you like). Then add the following line to your AppleVolumes.default. This is one line so be sure that there’s no line break in your AppleVolumes.default file:
/home/username/TimeMachine TimeMachine allow:username1,username2 cnidscheme:cdb options:usedots,upriv
Thanks to tsanga for pointing out the usedots and upriv options. The usedots option is required if you want to use invisible files and folders (those starting with a dot in the name). Otherwise afpd would encode them as :2e which is bad if you have to use invisible files (like .htaccess). If you’re on Leopard and have no Tiger installed Macs in your network or mixed OS X versions in your network you should use the upriv option which adds support for AFP3 unix privileges. If you have Macs with Tiger installed just use options:usedots to avoid unexpected behavior:
/home/username/TimeMachine TimeMachine allow:username1,username2 cnidscheme:cdb options:usedots
Finally if you want more stability and can accept slower file transfers you can use the dbd cnidscheme (cnidscheme:dbd).
Press Ctrl + S to save the document or choose File > Save. Of course you can define every folder you like or even an attached USB disk. Just define the correct path. External drives in Ubuntu should be found under /media
Finally restart Netatalk to activate the changes:
sudo /etc/init.d/netatalk restart
Although we now have a fully configured AFP file server it will not show up in the Finder sidebar on Mac OS X Leopard (but it’s reachable via Go > Connect to Server… in the Finder). Macs use a service called Bonjour for the sidebar thing (and for a lot of other cool stuff) and on the Linux side we can have this functionality with the Open Source implementation of Bonjour, called Avahi.
4. Install Avahi
So
the Avahi daemon will advertise all defined services across your
network just like Bonjour do. So let’s install the avahi daemon and the
mDNS library used for imitating the Bonjour service. When fully
configured this will cause all Macs in your network to discover your
Ubuntu box automatically:
sudo apt-get install avahi-daemon
sudo apt-get install libnss-mdns
To make everything work properly you have to edit the nsswitch.conf file:
sudo gedit /etc/nsswitch.conf
Just add “mdns” at the end of the line that starts with “hosts:”. Now the line should look like this:
hosts: files mdns4_minimal [NOTFOUND=return] dns mdns4 mdns
Press Ctrl + S to save the document or choose File > Save.
5. Configure Avahi and advertise services
Next
we have to tell Avahi which services it should advertise across the
network. In our case we just want to advertise AFP sharing. This is done
by creating a xml-file for each service inside /etc/avahi/services/
following a special syntax. Let’s create a xml-file for the afpd service
with the following line:
sudo gedit /etc/avahi/services/afpd.service
A blank document should open in gedit. Now paste the following into the document and save the file by pressing Ctrl + S or by choosing File > Save:
<?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>
update: The last part is used to assign a specific (Apple) hardware model to your Linux box. In this example your server will be advertised as an XServe and will be shown with this icon in the Finder sidebar. This will come in handy when you want to use your own icon for it or the one’s made by me provided within this article. Thanks to Simon Wheatley for figuring this out. Additionally you can use these models in this file: RackMac (same as Xserve), PowerBook, PowerMac, Macmini, iMac, MacBook, MacBookPro, MacBookAir, MacPro, AppleTV1,1, AirPort
Finally restart the avahi daemon to activate all changes:
sudo /etc/init.d/avahi-daemon restart
Now you have configured the Avahi daemon to advertise AFP sharing across your network which will cause your Ubuntu box to show up in Finder’s sidebar in Mac OS X Leopard. In Mac OS X 10.4 Tiger your Ubuntu server should now be visible under Network.
Now you’re done with setting up AFP file sharing on your Ubuntu box and advertising it across the network for Finder’s sidebar. Check if everything works as intended by clicking on your Ubuntu server in Finder and clicking on the “Connect As” button. Enter your username and password (the ones you’re using on your Ubuntu machine) and you should see the Volumes we defined earlier with the AppleVolumes.default file:
Another side effect of using AFP is that your Ubuntu box will show up as a nice Apple Cinema Display icon instead of the BSOD windows icon. Here you see my Ubuntu server showing up in Finder as Rockhopper:
update: If you’ve followed the revised version of this article your Linux box should now be represented by a Xserve icon in Finder:
6. Configure Time Machine
update 07/14/2008:
On the Mac side you have to enable the option to use network volumes as
Time Machine drives first. Without it your freshly shared and
advertised network volume won’t show up in the disk selection dialogue
in Time Machine. This is a hidden option not accessible via the
graphical user interface so you have to copy & paste this in
Terminal (it’s one line):
defaults write com.apple.systempreferences TMShowUnsupportedNetworkVolumes 1
Thanks to FoolsRun and tsanga for pointing this out in the comments
Now just mount the “TimeMachine” Volume first and choose it as a backup disk in the Time Machine system preferences. Time Machine will create a sparsebundle disk image inside the volume and mounts that too. This is needed because the hard drive on your Ubuntu box is formatted as ext3 or Reiserfs and not the native Mac format HFS+. Because Time Machine backups everything to the disk image all metadata (like creation dates etc.) will be preserved.
When your first Time Machine backup is done you can remove all Volumes and the next time Time Machine starts it will automagically mount the disk image from your TimeMachine volume on your Ubuntu box without mounting the whole TimeMachine volume:
7. Conclusion, Problems and more informations
You see that Linux and Ubuntu can be configured to behave like Macs in your network. But it’s sad, that you have to fire up the Terminal to achieve this. I hope especially the Ubuntu team will simplify this in future versions. Another sad thing is that Ubuntu is missing a useful avahi/Bonjour and AFP implementation for Nautilus, the file manager. So there’s no way to access your Mac from Ubuntu via AFP in the file manager. In my network I use SSH to access the Macs from Ubuntu or Linux by allowing Remote Login on the Macs in the Sharing preferences. But there’s a command line based AFP client available called afps-ng which uses the FUSE system.
Some other strategies of connecting Ubuntu/Linux and Mac OS X would involve sharing via Samba (Windows sharing) or NFS but according to my experiences nothing beats the speed, stability and secureness of AFP.
But if you’re interested you can have a look at this post on the ubuntuforums to learn how to setup NFS for file sharing between Ubuntu and Mac OS X Leopard.
Although I have checked all log files while using file sharing and especially while Time Machine is running and found no errors or warnings I cannot guarantee it’s working without errors or backup data loss on your system too. So I encourage you to check the system logs on Ubuntu AND on Mac OS X with the Console app in your Utilities folder. If you see no errors or warnings this configuration should be pretty bullet proof in terms of stability.
Finally the only problem remaining is that your Ubuntu or Linux box isn’t formatted as journaled HFS+ so some scenarios would fail or make problems. This can include having your iTunes, iPhoto or Aperture library on your Ubuntu server. But the cnid_meta daemon will always try handle that for us. This will cause some hidden folders to show up in Ubuntu which are used to store all the metadata required to almost reproduce a HFS+ file system. But if you ever run into problems you can easily resolve these by creating sparse disk images on your server with the Disk Utility built into Mac OS X. Just create a new sparse disk image on your desktop, copy it to your mounted Ubuntu volume and mount the copied disk image by double clicking it. Now you can put all the files and libraries in it which depends on HFS+
update 07/06/2008:
Problems with creating the backup disk image
If time Machine says “The backup disk image could not be created” during the first backup attempt you can do the following to avoid this problem and some others (backup fail due to permissions):
In short, you have to create the backup disk image on your Desktop and copy it to your mounted Time Machine volume. But Time Machine creates a unique filename for the disk image and we can find out this name with a little trick:
First open up the Console from your Applications > Utilities folder and open the Time Machine preferences. In Time Machine preferences set your backup volume back to none. After that reselect your mounted Time Machine volume. The counter should start and Time Machine’s big button will change to on. When the backup tries to start and fail have a look at your Console (Click All Messages in the sidepane). There should be a line tellung you the name of the disk image:
Creating disk image /Volumes/TimeMachine/computername_0014e3856bd0.sparsebundle
The computername should be the name you have assigned to your Mac. Now just click on that line and hit command + C to copy the message.
Now Open Disk Utility from your Applications > Utilities folder and click on New Image in the toolbar. Now just hit Command + V in the Save As field and remove everything before the name of the sparsebundle.
Update: The secret number Time Machine adds to your computer name is nothing more than the MAC address of the network device that your Mac uses to talk to your server, as Simulacrum and Todd found out in the comments. As he points out you can open up Network Utility and under the info tab you’ll find a field called “Hardware Address”. Just remove the colons and you have the number Time Machine adds to the disk image name.
In the field volume name write Backup of computername. Now FIRST chose sparse bundle disk image as the image format and THEN adjust the volume size to the size of your internal harddrive (minimum, choose more if you like) afterwards. Remember that Disk Utility won’t let you make a bigger image file as you have physical hard drive space available if you don’t chose sparse bundle disk image as the image format first. For reference have a look at this screenshot:
Select your Desktop as destination and click create. After the creation is finished drag the created disk image to your mounted Time Machine volume (you can delete the disk image on your desktop when copy is finished). Finally go to Time Machine preferences and start your backup again and everything should work as expected now. After the first backup (this can take a long time depending on your harddrive) you can unmount your Time Machine volume and the next time Time Machine starts it will grab and mount the sparse bundle disk image automatically (with “Backup of computername” as the volume name).
update 09/21/2008:
Firewall Settings
As Kevin points out in the comments you would have to adjust any firewall you use. But the standard Ubuntu installation won’t use any Firewall.
In short you have to allow communications over port 548 and 5353.
“Connection Failed”
If you get one of those errors:
"Connection Failed - There was an error connection to the server. Check the server name or IP address and try again"
or
"There was an error connecting to the server. Check the server
name or IP address and try again. If you are unable to resolve the
problem contact your system administrator."
you should first be sure you have either no firewall on your Ubuntu box in use or have it configured to allow AFP communications as suggested in the above paragraph.
Remember that this error can be caused by a myriad of problems and just a lot of other configurations on your side. So you should try a minimal way: On my Ubuntu boxes I have no other file sharing protocol like samba or NFS enabled (even not installed) so the samba hostname and the AFP hostname can’t interfere with each other. Also I’ve left the Workgroup field blank under System > Administration > Network > General tab.
If you still can’t connect to your Ubuntu box you can edit your /etc/hosts file as I’ve pointed out in the comments:
sudo gedit /etc/hosts
Add the following two lines at the very top of the file.
127.0.0.1 localhost
127.0.1.1 Rockhopper.local Rockhopper
My server is named Rockhopper, adjust the name according to your server name. There should be some sort of name already but the important part here is the servername.local which is the AFP way of server names. If there are any other numbers at the beginning in your file leave them as they are.
If that won’t solve the connection problems you can test out Eric’s solution as suggested in the comments which would involve removing and reinstalling netatalk.
Sorry I can’t give you any other solutions for that but in most cases it’s some sort of network misconfiguration outside of netatalk or avahi and on Linux these can be a lot of configurations on your side I can’t know of. And since I’m not able to reproduce these errors I can’t investigate in them.
But for those people still having problems with these error messages: On Mac OS X have a look in the Console app inside your Utilities folder. Click on “All Messages” in the left sidebar, try to connect to your Ubuntu box in Finder and see the messages in Console. These are the “real” error messages which normally will lead you to a solution.
-5014 error
Some people have problems when connecting to an AFP share and get a -5014 error. As J5 pointed out in the comments you have to delete the hidden .AppleDB folders on your Ubuntu box and restart netatalk afterwards:
sudo /etc/init.d/netatalk restart
Time Machine Full System Restore
In case of a full system restore you would have to boot your Mac from the Mac OS X installation DVD (the one delivered with your Mac) by pressing the c key during boot. Your Mac will start with a minimal UI where you have a Utilities section in the top menu bar. There you’ll find “Restore from a Time Machine Backup” but it won’t find your network share with your Time Machine backup. Luckily Dmitry Nedospasov found a way to manage this by simply mounting your Time Machine network share with the Terminal (which you can find under Utilities in the menu bar too) by utilizing the following syntax (shamelessly copied from Dmitry):
mount -t afp afp://username:password@hostname/ShareName /Volumes/ShareMount
Replace everything instead of /Volumes with your matching names. You can test if your network share was properly mounted by doing
ls /Volumes
which outputs the content of the Volumes folder and you should see your network share.
Now you can close the Terminal and select “Restore from Time Machine Backup” from the Utilities entry in the menu bar and select your mounted Time Machine backup and thats it. Oh, needless to say: a gigabit ethernet connection will speed things up dramatically even compared to (draft)n-WLAN.
update 12/07/2008:
Netatalk backup disk reaching maximum capacity
As Seron pointed out in the comments, there is some discussion on the net regarding problems with Netatalk and TimeMachine when the backup disk reaches maximum capacity. This is due to missing support for the AFP commands FPSyncDir aka commands 78 and 78 in Netatalk. As a commenter in an ArsTechnica forum says: “As soon as your backup volume will reach max capacity, it will self destruct because of it.”
In the forum you’ll also find some links to various patches to avoid problems with that. If you have tested such patch please post your experiences in the comments for this article.
More Articles
- In case you want to connect your iPhone via AFP: An AFP Server on your iPhone. This uses the Netatalk package too
- Netatalk 2.0 manual
- All possible AppleVolumes.default options (part of the Netatalk manual)
- Overview and templates about services Avahi can advertise
- In-depth article about Sparse Bundle disk images
- How-to: Get files off a Time Machine backup without using your Mac: In case you have to access Time Machine backups from Ubuntu or any other Linux system
- Using NetBSD, with guest account: Johannes laid down the steps to use NetBSD instead of Ubuntu.
8. Downloading and using the Server Display Icons
I’ve
quickly crafted a custom icon for your Ubuntu server. It’s the Apple
Cinema Display with the default wallpaper of Ubuntu 8.04 called Hardy
Heron. Additionally I’ve included an icon with the default Leopard and
the default Vista wallpaper to represent your Leopard and Windows server
too (The default Mac server icon uses the old Tiger wallpaper).
Here you can see the icons included in the Server Displays icon pack:
Because I’ve just modified Apple’s standard icons these icons are just available via this blog post and they will not show up in my Goodies section. Just download the whole package directly via this link:
v1.0 | 4 icons | zip-file | 5.5MB
How to use the icons
In the avahi configuration part in this article you have assigned the Xserve device info to your afpd.service file. All you have to do is to replace the generic Xserve icon (or whatever model you have assigned in your afpd.service file) with an icon from this icon package. Just rename the Ubuntu Server.icns to com.apple.xserve.icns and navigate to
/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources
Drag & drop the renamed file into this path and replace the generic icon (making a backup before doing that is a good idea) and after a logout all your avahi advertised Ubuntu servers should be displayed with the new icon (assuming that you assigned a device model in avahi).
If you’ve used another model in your afpd.service file, browse the Resources of CoreTypes.bundle to get to know the correct filename for the device icon and replace that file.
As for the Windows Vista server icon: Just rename the Windows Server.icns file to public.generic-pc.icns and navigate to
/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources
Now drag & drop the renamed file into this path and replace the generic icon (making a backup before doing that is a good idea) and after a logout all your Windows servers should be displayed with the new icon.
update: A solution for the icon problem is here: Simon Wheatley figured out how to assign a different icon to your avahi advertised Linux box. All you have to do is assigning a device info part at the end of the avahi service file for AFP. I’ve updated this article to include this part. Please head back to the Configure Avahi and advertise services part in this article and edit your afpd.service file again if you’ve followed the first revision of this article.
Congratulations! You finally arrived at the end of my article.
There’s a good chance that your coffee or tea cup is now empty. But
before making your next coffee you should share this article on your
favorite social website. Your vote is highly appreciated! After you’ve
finished voting and making your next coffee or tea you could subscribe
to my RSS- or Atom-Feed, discuss this article or buy me my next coffee
9. Translations Of This Article
The following articles are direct translations of my article but some of them are slightly modified or simplified. Remember that the authors/translators are responsible for the content.
German: Ubuntu + Apple Fileserver + TimeMachine on kde4.de
French: Tuto: Comment créer votre serveur Time Capsule sous Debian on the Blog of Pierre de la Celle
Article Updates
01/19/2009 added links to some translations of this article
12/07/2008 added a warning regarding the new undocumented AFP commands which maybe will be added by Apple with the Mac OS X 10.5.6 update
09/28/2008 added a link to the precompiled Netatalk .deb package from Alessandro
07/14/2008 added the Time Machine network volume hack under 6. Configure Time Machine
07/06/2008 added a new part Problems with creating the backup disk image
06/21/2008 added instructions for changing the server icons in Mac OS X
I have the same problem as the comment above. Any help with this would be greatly appreciated.
Aha!
Solution seems to be a couple of changes to the config files detailed here: http://www.tristanwaddington.com/2011/07/debian-time-machine-server-os-x-lion/comment-page-1/#comment-907
…although the AppleVolumes changes should reflect your own system paths and volumes. In my case, I just had to add the ‘tm’ option to my TM volume.
I managed to get a backup going by using netatalk 2.2b4.
Here’s what I did to configure netatalk (on ubuntu):
$ ./configure --with-cnid-cdb-backend --enable-debian --prefix=/usr
$ make
$ sudo make install
I ended up not using the cdb backend, but anyways.
I didn’t make any changes to /etc/netatalk/afpd.conf
I added the following to /etc/netatalk/AppleVolumes.default
/path/to/TimeMachine TimeMachine allow:user1 cnidscheme:dbd options:usedots,tm,upriv
Start up netatalk:
$ sudo service netatalk start
I shut down avahi-daemon, it doesn’t seem to be needed.
I then created the .sparsebundle image and placed it in my TimeMachine share. Backups working!
However, when the backup is finished, my image is named [computername].sparsebundle instead of [computername]_[computermac].sparsebundle. So when the next backup tries to find the image it is unsuccessful. If i rename the image back to [computername]_[computermac].sparsebundle it works again, but time machine renames it once again.
Any clues for this?
#!/bin/bash
echo $$ > /var/run/fixlion.pid
while true; do
mv /path/to/backup/computername.sparsebundle /path/to/backup/computername_MAC.sparsebundle 2> /dev/null
sleep 60
done
make it run as a service creating a file named “fixlion” in /etc/init.d
#!/bin/bash
case "$1" in
'start' )
/path/to/script
echo "Fixlion started"
;;
'stop' )
kill -9 `cat /var/run/fixlion.pid`
rm /var/run/fixlion.pid
echo "fix lion stopped"
;;
Make both scripts executable (chmod +x filename). To adjust the interval between rechecks change “sleep 60″ to whichever value (in seconds) you want.
Start/stop the service with
service fix lion start
service fixlion stop
It’s not the best nor the most elegant way to do it but it’s as far as I can go. Hope it’ll work.
For Fedora / CentOS users I came across this site with a source rpm of Netatalk 2.2 (haven’t tried it yet):
http://www003.upp.so-net.ne.jp/hat/netatalk/rpm.html
For Lion compatability, install the 2.2 beta 4:
http://ubuntuforums.org/showthread.php?p=11071171
If you can’t or don’t want to upgrade your ubuntu server for Lion, this fix worked for me: http://www.alexanderwilde.com/2011/04/os-x-lion-connection-error-with-afp-and-workaround/
Here is a quick explanation how to install netatalk 2.2~beta4 on Debian: http://www.genthree.com/running-netatalk-2-2beta4-1-on-debian-squeeze
As of today (August 6), Ubuntu 11.04′s version of Netatalk can be installed directly from apt-get without doing the reconfiguration and will work straight “out of the box”, even supporting native Time Machine.
Hi Lionel, I’ve tried the latest ubuntu & netatalk and I still get the same error afp compatibility error. It does not work straight out of the box as yet.
I’ve tried Ubuntu 11.04 and everything worked fine with no configuration. The only problem I had was when setting up volumes, make sure if you specify cnidscheme, that you use bdb. This (for me) prevents the message about “Something wrong with the volume’s CNID DB, using temporary CNID DB instead. Check server messages for details!”.
Example:
/bwd bwd allow:jess cnidscheme:dbd options:usedots,upriv
I’m having a problem with the “sudo gedit /etc/default netatalk”. When I open it, there appears:
Gtk-WARNING **: Attempting to store changes into ‘/root/.local/share/recently-used.xbel’, but failed to create file ‘root/.local/share/recently-used.xbel.FXY0ZV’: No such file or directory
I’m not very familiar with Linux, so i have no idea what this means, but I’m guessing this prevents the setup from working.
Anyone that can help me?
hey krema,
u rock dude!!!
u’re right, after following this tut and system operating for almost two years i lost my music hdd, thus i decided to try the NFS way.
i was very unhappy when verified a poor speed over ethernet and wi-fi even N standard.
therefore i’m going back on AFP, configuration is harrier but speed and security control are way better!!!
thanks and best regards!!!
great article and it worked after à little tweak because Of Lion, thanks a lot
I was just to quick, here’s the link for the little tweak
http://www.trollop.org/2011/03/06/netatalk-afp-mac-os-x-10-7-lion/
Thanks for the great article, still highly useful after all this time!
I used it to set up netatalk-2.2 on Ubuntu Natty just yesterday.
However (as always), even though I can see the shares fine in Finder, Time Machine does not recognise the share I have setp up for it, it simply is not listed in the volumes that pop up when I choose “select disk”.
Any hints on what could cause this?
Here’s a snippet from my AppleVolumes.default:
> /server/files/backup/TimeMachine TimeMachine cnidscheme:dbd options:usedots,upriv,tm
hi, Thanks for this informations, but i have problem with lion 10.7.1,
i have message “The disk backup network does not support the functionality required AFP.” My drive is mounted. I can read and write it.
Thanks for your help.
You have to use a newer version to make it work. There is a beta available that I use and that works. You can read about it here: http://www.trollop.org/2011/03/06/netatalk-afp-mac-os-x-10-7-lion/
Good Luck
yep, the roof is on fire!!!
http://www.netafp.com/open-letter-to-the-netatalk-community-501/
http://www.matthewgkeller.com/blog/2011/07/07/open-response-to-open-letter-to-the-netatalk-community/comment-page-1/#comment-31461
I really don’t want to use a beta release!!!
Let’s pray for the best!!!
Hi Kerma,
Really nice howto on turning the server to a mac file server for office environments. But i have a stability question.
How stable is the workflow from within finder ? i want my 2-3 people to work on files straight off the server. Have you noticed anything unstable regarding a workflow like this ?
Best Regards
Thomas
Everything went fine on Snow Leopard, but when I try to run TimeMachine on the new Lion OS X, I get the following error message:
Time Machine could not complete the backup. The network backup disk does not support the required AFP features.
This problem is well known as far as:
http://web.me.com/pondini/Time_Machine/C16.html
Is there any upgrade/solution that applies to our Ubuntu hack on a 10.04 LTS?
I had this working on my server so everyone in the office could backup their macs. When Lion came out I upgraded netatalk on the server and now when I mount the drive on Time Machine and go to backup it failts with this error, “The network backup disk does not support the required AFP features.”
Can someone shed some light on this issue please?
Hi
I walked through tutorial and everything seemed to be fine.
I can see my ubuntu in finder.
When I click connect as and putting my ubuntu credentials I can’t log in.
What may be a problem? please help
Firstly, Krema. Thanks a million. Have used this site about four times over the last 3 years. It’s pure gold.
However, Matt, if you have just built a new Ubuntu server there are a couple of changes.
1. With Ubuntu 11.x the default Netatalk package is built correctly with encryption – so you can skip section one and grab the package. >sudo apt-get install netatalk.
2. When configuring afpd.conf add uams_dhx2.so NOT uams_dhx.so to the -transall line. This will allow you to connect correctly from your client.
3. I would recommend that you use dbd rather than cdb for your cnidscheme in /etc/netatalk/AppleVolumes.default.
A full Lion description please:
As usual my Ubuntu (10.04) conspires against progress; in particular against me backing up a brand new iMac running Lion.
I’ve gone through this tutorial, setup the iMac to allow network disks and installed Netatalk 2.2 and tweaked afpd.conf and AppleVolumes.default and although I mount AFP volumes I can’t backup from Lion: Error 45.
Can someone please flush out detailed and comprehensive instructions or point to some tutorial that is complete and not full of broken or obsolete links?
I’m using the netatalk 2.2 package and am able to successfully backup using Lion. However, my setup is a bit different. I use a specific user (‘backup’) for Time Machine. In the home directory for the ‘backup’ user is a single file -> .AppleVolumes
/home/.timemachine backup options:usedots,upriv,tm
NB: This presumes you have created a directory in /home names .timemachine and it is owned by the user ‘backup’.
I believe the key might be in the “tm” option, which allows the Macs to see the box as a real Time Machine device. I haven’t had to setup the Macs to use unsupported network volumes; all of the Macs see it as a Time Capsule, basically.
Oh, one other thing: if you are upgrading to netatalk 2.2 from a previous version you might have to delete the CNID databases. Apparently the format changed and you can get DB errors when logging in.
Just rm -rf /path/to/share/.Apple* and you should be good.
The CNID dbs will be recreated when netatalk is restarted.
Just a note for all Fedora users: remember to configure the firewall!!
I’ve spent about 5 hours trying to get netatalk working without avail until I decided on a whim to:
$ sudo service iptables stop
.. and it started working! So in other words, make sure the firewall is set up properly.
Guys
So is there a solution for Lion? no beta packages or easy to install beta? please help
Yes. I have it running on Lion 10.7.2 with an Ubuntu 10.04 backend. On Ubuntu I just did:
sudo apt-get remove netatalk
sudo apt-get install netatalk
This got me a default netatalk 2.2.x
I also installed (apt-get) some cryptolib (search the links above) which could have or not contributed to success.
On the mac side just enable network volumes and then mount the disk. There is no need to create the sparsebundle image. Lion does this automatically.
Anyone know how to get netatalk 2.2 to install on Ubuntu Hardy ?
netatalk 2.2.1 and Lion solution
After compiling the above netatalk the backup didn’t work.
that version adds a “:DEFAULT: options:upriv,usedots” line. and uses that options instead of my share definition
To fix add a “,tm” also to that line
Thanks for a great tutorial. All seems to work perfectly on Centos until i try to run a backup.
afpd spits this into syslog:
Nov 8 16:55:08 bp-host1 afpd[22894]: ASIP session:548(5) from 192.168.2.105:63014(7)
Nov 8 16:55:08 bp-host1 afpd[22436]: server_child[1] 22894 done
Nov 8 16:55:08 bp-host1 afpd[22895]: ASIP session:548(5) from 192.168.2.105:63015(7)
Nov 8 16:55:08 bp-host1 afpd[22895]: DHX2 login: rene
Nov 8 16:55:09 bp-host1 afpd[22895]: DHX2: logincont2 alive!
Nov 8 16:55:09 bp-host1 afpd[22895]: PAM DHX2: PAM Success
Nov 8 16:55:11 bp-host1 afpd[22895]: DHX2: PAM_Error: Authentication failure
Nov 8 16:55:11 bp-host1 afpd[22895]: 0.51KB read, 0.38KB written
Nov 8 16:55:11 bp-host1 afpd[22436]: server_child[1] 22895 done
And the backup itself fails with:
Time Machine could not complete the backup
The backup disk is not available
I’m running OS X 10.6.8 + Centos 5.6
Has anyone successfully setup Avahi to advertise CUPS printers under this setup? I’m running Netatalk 2.2x and if I call avahi-discover I don’t see my printer. Help please.
Isn’t this a setting that you enable in cups-config?
http://en.gentoo-wiki.com/wiki/Avahi#Cups
or do you want to generate service-files for avahi?
http://atxconsulting.com/blog/tjfontaine/2010/11/21/automatically-generate-airprint-avahi-service-files-cups-printers
You are the best – thank you so much– -lets hope it will work
Has anyone succeded with mounting the server in Finder so that the user’s home folder show up immediately? When I login to the network server in Finder I find myself in the “/home” folder on the server, not in “/home/”. I have to click on the username to be able to see the network disk in Time Machine. This is not a problem when at home, but I’m trying to make it work at the job.
best regards
…should be “/home/” ….-)
awesome tutorial. i have had to build netatalk 2.2.1 for usage with lion, but besides that, everything described in here worked like a charm!
What are the instructions to setup the TimeMachine directory for my home folder on a different hard disk. I am asking for help with the exact commands I need to type.
Anybody have this solution working with Ubuntu 11.10, Lion 10.7.2, and Netatalk 2.2.1?
I can mount the AFP share as a volume, write files to it, and Time Machine allows me to select it as a backup volume. When a backup is attempted, I always get these errors:
com.apple.backupd: NAConnectToServerSync failed with error: 80 for url: afp://xxxxx@hostname/afp
com.apple.backupd: Backup failed with error: 19
I’ve tried numerous combinations of configurations for the afpd.conf and AppleVolumes.default and it’s always the same result. I compiled Netatalk 2.2.1 manually and here is the output of my configure command:
Using libraries:
LIBS = -lpthread -L$(top_srcdir)/libatalk
CFLAGS = -I$(top_srcdir)/include -D_U_="__attribute__((unused))" -g -O2 -I$(top_srcdir)/sys
SSL:
LIBS = -L/usr/lib64 -lcrypto
CFLAGS = -I/usr/include/openssl
LIBGCRYPT:
LIBS = -L/lib/x86_64-linux-gnu -lgcrypt
CFLAGS =
BDB:
LIBS = -L/usr/lib64 -ldb-5.1
CFLAGS =
Configure summary:
Install style:
debian
AFP:
Large file support (>2GB) for AFP3: yes
Extended Attributes: ad | sys
CNID:
backends: dbd last tdb
UAMS:
DHX ( SHADOW)
DHX2 ( SHADOW)
RANDNUM ( SHADOW)
passwd ( SHADOW)
guest
Options:
DDP (AppleTalk) support: no
SLP support: no
Zeroconf support: yes
tcp wrapper support: yes
quota support: yes
admin group support: yes
valid shell check: yes
cracklib support: no
dropbox kludge: no
force volume uid/gid: no
ACL support: yes
LDAP support: yes
here is my config for:
afpd.conf:
- -transall -noddp -uamlist uams_dhx2_passwd.so -nosavepassword
AppleVolumes.default:
/mnt/time_machine "time_machine" allow:xxxxxx cnidscheme:dbd options:usedots,tm
Quick praise, followed by a question. This is my first real foray into Linux (Lucid), as I’ve been tasked with creating a small file server for my work. Between this tutorial and applying the Share function in Ubuntu (Nautilus), I’ve got this PowerPC G4 Lucid install showing up on OS X 10.5 clients. From someone who remembers a few DOS commands from 15 years ago, thank you Kerma.
Although I’ve run into a bit of a snag. While I’ve configured the volume to accept new files, I can’t save edits made to files directly on the server. For instance, if I open a .doc file in Word 2008, it opens as “Read Only.” If at all possible, I’d like to be able to edit files on the Lucid server without having to save a local copy and overwrite the previous one.
Is this possible? My thanks in advance!
Hi FreddyB, I have tried several times to get this to work as a files server so that different users can edit files. I have had several, very advanced Ubuntu experts helping me out with the permissions problem, and although they all say “this should work”, it never does, and when they try it themselves, they have the same problem with permissions.
Basically, this only works as a “one User” Network Attached Storage. It cannot be used as a file server.
For anyone experiencing issues with the OSX Finder reporting “Connection failed” when connecting to an advertised Samba-service. I posted an article on what could be the cause.
You can find it here, if you are interested:
Link here, since it did not show in my last post.
http://bwyan.dk/?p=1456
Hi, does anyone know if extended acl is supposed to work already because the following strange thing is happening:
when using the mac to create a new dir on the share everything works ok i can chek on the oneiric box and see that the extended acl is set
When creating a file the ext acl doesnt get set and only the owner can write but then when i manually set ext acl for a certain user it does work. So somehow the extenden perms are recognized but if you createe a new file from the mac they are not implemented but on directory’s they are. Does anyone know why or even better is ther a solution
Total awesome sauce, I’m restoring my MBP right now over the network. I used Lion, the only thing I had to change was that I had to manually create the mountpoint before doing the afp mount. A simply #mkdir /Volumes/Backup before mounting the drive worked just fine.
Thanks.
Thanks, I’ve been looking for this everyone. I know I’m late in finding it, but thanks for adding the tutorial.
thank you for this .. it´s help me a lot ..i did a translate of this post in portuguese , i hope you like , if you can see the link is it
http://geektrouble.blogspot.com.br/2011/11/mac-file-server-no-ubuntu-1004.html
For the record, a2boot is for netbooting Apple II’s via AppleTalk.
Instead of using the command
defaults write com.apple.systempreferences TMShowUnsupportedNetworkVolumes 1
, create an empty file on the TimeMachine share with the name .com.apple.timemachine.supported (touch .com.apple.timemachine.supported
). This will make OSX think that the drive is a real TimeMachine drive – especially helpful when doing a full restore.Hi, I have configured two separate systems using this great guide. However, I am getting one problem when i connect to one of the servers the shares that show in the other change i use the same username to connect to both and they both have different server names. does anyone know how to fix this ??
I haven’t read through all 913 comments to see if this information has been proffered – but here it comes(in regard to a2boot and what it does):
To accommodate netbooting, the a2boot daemon should be found in /usr/sbin/a2boot and needs to be enabled in /etc/default/netatalk. Look for the A2BOOT_RUN setting and set it to “yes”. Create the /etc/netatalk/a2boot directory and copy the IIe and IIgs network boot blocks into that directory. The boot blocks can be found in http://peterwong.net/files/apple2/troika-3.tar.gz
This howto is completely broken for ubuntu 12.04.1. For example, the following auth modules do not work AFP sharing: uams_randnum.so,uams_dhx.so
Also, editing nsswitch.conf is not needed at all.
In short, this article wasn’t very useful.
a more state of the art post can be found here:
but it is for raspberry pi (raspbmc), but shall also work for “full” linux debian dists.
http://www.andadapt.com/2012/09/06/raspberry-pi-raspbian-hfs-afp-and-time-machine/
This is AMAZING, but it doesn’t work with Mountain Lion. Apparently you have to add some arguments to your uamlist (I have no idea what I am doing here, but these changes worked for me http://itfuzz.blogspot.com/2012/09/ubuntu-1204lts-afp-and-osx-mountain.html)
In /etc/netatalk/afpd.conf make sure -uamlist includes uams_guest.so and uams_dhx2_passwd.so:
-uamlist uams_guest.so,uams_dhx2_passwd.so
In /etc/default/netatalk make sure your uams modules are enabled (uncommented), mine looks like this:
AFPD_UAMLIST=”-U uams_guest.so,uams_dhx2_password.so,uams_clrtxt.so”
Yay works in Mountain Lion (at least the afp shares, haven’t gotten TimeMachine to show up).
To get your TimeMachine entry to show up in /etc/netatalk/AppleVolumes.default you have to make sure your time machine line specifies the option “tm” so instead of:
/home/username/TimeMachine TimeMachine allow:username1,username2
You need:
/home/username/TimeMachine TimeMachine allow:username1,username2 options:tm
And magic happens.