Life, Football, Technology and Vespas…

Linux & OSX – Side by Side

Time MachineAfter my bonjour woes yesterday, I started to fish around and read up some more about bonjour. It is a very useful protocol but what stood out for me was that services can be advertised on linux via bonjour. I knew that this was possible but did not fully appreciate the capabilities. I have hacked around before to get a time machine disk that has been shared using samba from linux, working on Mac, but I never knew that it would be so easy to do it via bonjour using avahi and netatalk – both opensource tools.

Install and configure netatalk. I used Fedora 11, so yum install netatalk. Do what you need to do on your distro to install. The edit the config file:

# vi /etc/atalk/netatalk.conf

# Set which daemons to run (papd is dependent upon atalkd):
# Set which daemons to run (papd is dependent upon atalkd):

papd is used for sharing attached printers on your linux box to other Mac boxen. CNID_METAD_RUN=yes is very important as it is likely your file systems are not hfs+, so you need this to handle the metadata.

Next edit the file /etc/atalk/afpd.conf and check that the last line at the bottom is:

- -transall -uamlist, -nosavepassword -advertise_ssh

Time MachineNow you need to add a shared volume. Here I will show you how to share users’ home directories and how to add a volume that you wish to use for time machine backups. Edit the /etc/atalk/AppleVolumes.default file and add a ~ to the bottom of the file if it is not allready there:

# vi /etc/atalk/AppleVolumes.default

The above will allow users’ to share their home directories to their Mac machines. To add a volume for Time Machine, Add the following line (editing it to your prefs) to the same file at the bottom:

/Volumes/TimeMachine	 TimeMachine allow:username1,username2 cnidscheme:cdb options:usedots,upriv

Where username1 and username2 are the users that are allowed to access the volume. You can now start netatalk and set to start at boot –

# /etc/init.d/atalk start
# chkconfig atalk on

The next thing is to configure avahi daemon – install first if not already done so:

# yum install -y nss-mdns
# yum install -y avahi-compat-libdns_sd
# yum install -y avahi

Edit /etc/nsswitch.conf to look as follows:

hosts: files mdns4_minimal [NOTFOUND=return] dns mdns4 mdns

Avahi needs to be configured so that it knows which services it should advertise. Just for now, we are only advertising the afp sharing service. To advertise the service we add the following service config file:

vi /etc/avahi/services/afpd.service
<?xml version="1.0" standalone='no'?><!--*-nxml-*-->
<!DOCTYPE service-group SYSTEM "avahi-service.dtd">
<name replace-wildcards="yes">%h</name>

Thats it! All you need to do now is start the avahi-daemon

# /etc/init.d/avahi-daemon start

Opening up your finder in mac should now show your linux machine in the ‘Shared’ section on the left:


If you look closely, you will see that the icon is not a BSOD windows icon, but actually an Xserver icon


The last couple of things that you must do is instruct your Mac to use ‘unsupported network volumes’ :

defaults write TMShowUnsupportedNetworkVolumes 1

Disk UtilityAnd a bit of hack – but if you have an issue writing to the backup disk for the first time using Time Machine, then you may need to create a sparse image locally and then copy over to the mounted image. Creating the sparse image is easy enough. Open disk utility and from the file menu select – New -> Blank Disc Image

To get the file name that Time Machine wants to use – It is simply the joining of the machine name and the MAC address of the device that the backup will be performed over. In my case the name would look like – bonobo_pro_00236c8e678c.sparsebundle

Save SparseBundle

It can be seen that I changed the image Format to sparse bundle disk image. Once the file has been created, it can then be copied to the volume that you wish to use for your time machine backups – and then Viola! You can enable Time Machine.

As I find out what else I can do with bonjour, mac & linux – I will post up here…


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s