Using Ubuntu as an Apple File Server

First things first – I’m not taking credit for this. I was sent this link from a friend and the only reason I’m writing it out here is in case that blog goes offline in the future. He does an excellent job explaining everything, so I suggest you go look there for detailed instructions. Secondly, since I’m sure most people who read my blog won’t care about this, I’ll split the post here before going on. :)

1. Modify and install Netatalk

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.

Now fire up your Terminal and execute the following lines.

sudo apt-get build-dep netatalk
sudo apt-get install cracklib2-dev fakeroot libssl-dev
sudo apt-get source netatalk
cd netatalk-2*

Next you have to build the Netatalk package with the encryption option enabled:

sudo DEB_BUILD_OPTIONS=ssl dpkg-buildpackage -rfakeroot

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

2. Configure Netatalk

sudo vi /etc/default/netatalk

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

Next we have to edit the main config file for AFP sharing called afpd.conf:

sudo vi /etc/netatalk/afpd.conf

Scroll to the very bottom of the document (shift-G) 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

3. Configure shared Volumes

Now we have to tell the afpd daemon what Volumes to share.

sudo vi /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

Finally restart Netatalk to activate the changes:

sudo /etc/init.d/netatalk restart

4. Install Avahi

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

5. Configure Avahi and advertise services

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

A blank document should open. Now paste the following into the 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>

Finally restart the avahi daemon to activate all changes:

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

Leave a Reply

 

 

 

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>