In order to mount NFS shared on OSX Mountain Lion the manual way, use the terminal (just the same command as on ubuntu!)
sudo mount localhost:/media/share /mnt
That’s great, but how about automating it so that it is automagically available in finder once the computer boots?
There is an application called netatalk that can achieve this… “Netatalk is a freely-available Open Source AFP fileserver. A *NIX/*BSD system running Netatalk is capable of serving many Macintosh clients simultaneously as an AppleShare file server (AFP).”
With Ubuntu 12.04, unlike other ubuntu revisions, netatalk is available as the correct version and it works straight out of the box (after some simple configuration):
Firstly install
sudo apt-get install netatalk
Modify /etc/netatalk/afpd.conf, and remove the last line so it looks like
- -tcp -noddp -uamlist uams_dhx.so,uamx_dhx2.so -nosavepassword
By default, the home directory of users will be made available. Modify /etc/netatalk/AppleVolumes.default and add the desired shares, for example add to the bottom to share the /media/backups directory:
/media/backup "Backup for users" allow:@usergroup options:usedots,upriv
Start the netatalk service
sudo /etc/init.d/netatalk restart
So far we have created AFP shares for use with OSX. Now we must publish them so that they will be automatically displayed in finder – make it easy for our users!
Avahi helps advertise services to systems, so once installed it will tell our OSX machines about our new AFP shares….
sudo apt-get install avahi-daemon libnss-mdns
Modify /etc/nsswitch.conf and add “mdns” to the end of the “hosts:” line. Make it look as per below:
hosts: files mdns4_minimal [NOTFOUND=return] dns mdns4 mdns
Next, create /etc/avahi/services/afpd.service with the contents below, in order to advertise the required services:
<?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>
Start the avahi service by running:
sudo /etc/init.d/avahi-daemon restart
Then, open finder and the server should be displayed in “shared” section. As above, the icon can be configured to show one of MacPro, Macmini, iMac, Xserve, MacBook, MacBookPro and MacBookAir (all MacBook’s icons are the same…)
Choose the one that best fits your server, MacPro will do for now.
Select the new server, and click “Connect As…”. Enter the username/password for a user configured on the ubuntu server and the contents of the “Home Directory” will be displayed.
Once mounted, the mount command (on OSX) outputs the following
//ubuntu@ubuntu._afpovertcp._tcp.local/Home%20Directory on /Volumes/Home Directory (afpfs, nodev, nosuid, mounted by user)
In the next post, I will describe some issues and setup of ubuntu accounts for the purposes of AFP shares.
Thanks to pwntr and missingreadme for the tips and tricks to get this working.