ARgh, this should be so simple, but it isn't. Trying to build a linux file server is complicated mainly because of the network naming (how do you file your server) and the administration of users. Here's a quick guide for Ubuntu. It is amazing to me it took a whole day and a half to write this
Out of the box
Xubuntu as a client
Avahi supports Mac file sharing via afp (natively!). You can browse and you can connect from Xubuntu to a real Mac. Wow that is pretty cool.
- It actually doesn't work against Synology file servers which Mac's can see
It doesn't work against Time Capsule 2nd Generation at least even though they are AFP devices
Ubuntu as a server
If you are testing then you want to make sure that:
- in a VMware virtual machine, make sure that the machine is a "full" peer. The default is to share with the Mac and this will put the VMware machine on 172...* usually. And we want it to be visible. However out of the box:
Change your hostname to something reasonable. Change your hostname in /etc/hostname and /etc/hosts and then reboot. The default is
ubuntu which isn't very good. To make the change permanent you run this where $new_hostname is whatever you pick and here's a rough sketch of what is going on (although this script fails if the hostnames have strange characters loved by sed or bash like single or double quotes.
new_hostname=rich-ubuntu # Need the old hostname so easy to remove from /etc/hosts old_hostname=$(hostname) sudo hostname "$new_hostname" # change the hostname permanently sudo tee /etc/hostname <<<"$new_hostname" sudo sed -i "/^[!#].*$old_hostname/d" /etc/hosts sudo tee /etc/hosts <<<"127.0.0.1 $new_hostname"
Avahi should already be installed but if you've change the hostname, you need to reboot so that it takes effect and you so you should be able to go to your Mac and browse
- so try,
ping rich-ubuntu.localand see if you get anything. This tells you the basic IP discover is working
Use the iPhone Discover application to see what properties are being offered by the system, by default with no Samba, it offers a single Bonjour service called the Workgroup manager service. Under the covers, Bonjour uses a DNS variant called mDNS-SD (multicast DNS service discovery). It is pretty simple, when you arrive on the network you respond to queries such as
what file servers are there, then every client that is on the same subnet caches those responses. Since it is multicasting one packet essentially updates all the client on the network. It manages a special domain
.local and overloads the TXT and other DNS records with information.
You can see if this is working by looking at
/var/log/syslog and see if you get avahi events. Also run
tcpdump and see if you can find avahi packets, although
avahi-browse is easier to read.
As a kind of cool aside, if you put
.local in your search entry in the network pane, then you can just type
rich-ubuntu and not
rich-ubuntu.local as a convenience.
An aside on how Avahi (aka Bonjour, aka Rendezvous works
When a computer starts, it looks for an open IP address (probe and then take), then publishes it's DNS address (an A record) and if there is no rejection takes it, then sends a multicast of SRV records for every service it has. The format of the service is:
- The format of the services is the traditional reverse naming, so it starts with the domain, then the
_protocolname, then the
_serviceand then the (registered with the iana, then the user friendly name that is added a DNS SRV record
Rich's file server._smb._tcp.localmeans in the domain local, over TCP/IP, is the protocol for server message blocks (the Window file server) and the name of the server is
Rich's file server. The Apple file protocol name is
In the SRV record is the TTL (time to live which is ignored) and the gold mind which is the actual hostname and port where you access the service. The PTR record is used to make it easy to take a general service like and point it at a particular instance so
_printer._tcp.local. means any printer on the network and it can point to
The TXT record is then used for multiple queues or things in the same SRV, so you can use it to further differentiate a SRV.
When a machine goes away, it will be around until it hits the TTL (time to live) in its A record which is why you see servers that no longer exist live a while.
IN the real world, the only service advertised is
_workstation._tcp on port 9 which only the Synology servers we have (but not Mac OS X) advertises.
Install File Sharing
Unlike Ubuntu, Xubuntu uses Xfce for windowing which uses the Thunar file manager as it’s environment and which uses Gigolo as a file sharing client. The internet is littered with broken guides on how to make it all work. There seem to be a few approaches: a) Samba, b) Gigolo and c) Nautilus. I’ve tried Samba and it doesn’t seem to allow file sharing. Ubuntu uses Unity which is uses Gnome which uses the Nautilus file manager.
But here is what you need to turn it on:
- A huge problem with Xubuntu is that there appears to be no way to just search for a graphical application that I can find, so searching for “Share” doesn’t work. Instead, you have to know the name of the application and start it in Terminal. It is the Gnome application:
Then you have to choose Unlock at the bottom otherwise everything is greyed out. Then you need to pick a user name and a file location. Make sure to click off Read-only and it seems to work. Interestingly Avahi appears to update automatically. Sigh 24 hours to figure this out!
File Sharing is embedded in Xubuntu ways that don’t work
It is really a disadvantage working on a nth tier release. According to Distowatch, Mint (based on Ubuntu), Ubuntu and then Debian are the top three distributions. So be warned. Might try Mint.
Xubuntu doesn’t support ssh daemon by default, so to manage this file server, you need to:
- So you can administer the thing, get ssh with
apt-get install openssl-serverand then you can ssh in with the user account. On this machine with XFCE windows, it isn't obvious, the name of the system is
whoamiand the name of the machine is
hostname'. If you don't like these names, then there doesn't seem to be a graphical way to change this, so just do a sudoecho new-host-name > /etc/hostname
and then you need to also change/etc/hosts`
Installing Samba didn’t work
- Installations include
sudo apt-get install -y gksu system-config-sambawhich gives you Samba, the basic file sharing on a vanilla desktop version of Xubuntu. The firewall is turned off by default, but if you have it on, you open up the ports with
sudo ufw allow samba
Now you want to create a share, you have to start the system-config-samba and set up the file share and the writable, visible and in our case we allow all users to access.
You will want to load up a disk and create some shares. This isn't built into xubuntu, you need to do an
sudo apt-get install gnome-disks and then from the terminal run
gnome-disks and then create partitions. Note also that things like gnome-disks is graphical yet it isn't automatically found. You need to start.
- You need to install and build netatalk with encription to be able to use AFS so it works with Macs too.