Subscribe via RSS
administration c# cocoa coding EasyTAG linux Mac OS X opensolaris OpenVPN Time Machine virtualization windows xcode zfs

ZFS and Apple TimeMachine – a perfect Team

There is a corresponding post, which provides updated additional instructions to make this work with Mac OS X Lion (10.7)

I had this article lying around for about a year as a draft now – recently I fixed the avahi TimeMachine advertising and I thought finishing up and publishing this article would be a good thing.
Of course some things have changed, like most recent versions numbers and Opensolaris … but it should not matter if you try this on Opensolaris B134 , Illumnos or Solaris 11 Express because the internals are almost the same :

Until now I used to exchange files between my MacBook and my HomeServer running Opensolaris via the smb protocol. Sadly this is far from perfect because smb does not support some of the Apple specific network filesystem stuff.
It gets especially nasty with Snow Leopard and TimeMachine. In 10.6 I could not get TimeMachine to work properly with samba – so I decided to take the time and configure my OpenSolaris to be an AFP server too.
It turned out that this was rather easy either way, especially with netatalk 2.0.5 and above having "extended" TimeMachine Support via the "tm" switch.

Even cooler ZFS provides you with quota options and additional transparent compression for your TimeMachine backups …

Here are the steps I performed.

If you haven't compiled anything manually on your OpenSolaris box, an easy way to get a gcc development platform is installing the gcc-dev package :

pfexec pkg install gcc-dev

 


 

Table of contents :
» Configure a ZFS filesystem for use with TimeMachine
» Installing Berkely DB
» Installing Netatalk
» Configurin Avahi
 


Configure a ZFS filesystem for use with TimeMachine

If you do not already have a seperate filesystem for the TimeMachine Backups, I recommend making a seperate one for each TimeMachine client. It's very easy and introduces only minimal overhead with ZFS.
ZFS provides very useful options for its filesystems among them are quotas and transparent compression.
Quota is very useful because you can easily limit the timemachine's backup size and prevent filling it up your whole pool. I recommend setting the quota to at least 1.5x the size of your Macs harddrive if you can afford. That way even with an almost full harddisk you can keep some older backups in your timemachine (always depending on how much you change between timemachine cycles). For the 160GB HD in my MacBook this means 250GB backup space on the ZFS filesystem.
Very cool is zfs transparent filesystem compression. TimeMachine does not use compression and afaik it can not be turned on manuall either. So you just tell your zfs to compress everything TimeMachine writes to it by issuing the simple command mentioned below. This will turn on standard ZFS compression, which is a good trade-off in terms of compression/speed ratio. If you want to use a more agressive compression scheme, just look up the compression part in the ZFS manual.

# replace POOLNAME with the name of the pool you want to
# add your timemachine backup to (the pool has to exist)
# make the filesystem if you haven't already one
zfs create POOLNAME/timemachine
# set a quota on the filesystem
# ! adjust this to your needs and disk Space
zfs set quota=250G POOLNAME/timemachine
# enable compression
zfs set compression=on POOLNAME/timemachine

 

Install Berkeley db

The Berkeley db is the database backend needed by netatalk to store all kind of stuff.

You have two options for installing it :
1. Use the "unofficial" package from the OpenSolaris Contrib repository
2. Compile and install it on your own

I prefer the second one for now, because I consider it less likely that a dist upgrade of bdb breaks my netatalk – and the bdb in the contrib repository is not the newest version.
The downside is you have to manually install and "mantain" it.
Your choice …
 

Easy Installation

Via the Package Manager from the Opensolaris Contrib Repository

http://pkg.opensolaris.org/contrib/en/catalog.shtml

Find the "bdb" entry and click on the "Install" Button, then follow the instructions from the Packetmanager

Manual Installation

Download the latest version from
http://www.oracle.com/technology/software/products/berkeley-db/db/index.html

move to an appropriate place, configure, build and install it

mkdir ~/netatalkBuild
mv ~/Downloads/db-X.X.XX.tar.gz ~/netatalkBuild && cd ~/netatalkBuild
tar xvfz
db-X.X.XX.tar.gz
cd
db-X.X.XX/build_unix
../dist/configure --prefix=/usr/local
make -j 4
pfexec make install

 

 

Install netatalk

Download the latest netatalk package from
http://sourceforge.net/projects/netatalk/files/

mv ~/Downloads/netatalk-2.X.X.tar.bz2 /usr/src && cd /usr/src
tar xvfj
netatalk-2.X.X.tar.bz2
cd
netatalk-2.X.X
./configure --disable-ddp --without-pam
make -j 4
pfexec make install

 

Configure netatalk

If you haven't set up a filesystem for TimeMachine Backup, look here and then continue.

Edit the netatalk configuration files in /usr/local/etc/netatalk/

netatalk.conf
ATALKD_RUN=no
PAPD_RUN=no
CNID_METAD_RUN=yes
AFPD_RUN=yes
TIMELORD_RUN=no
A2BOOT_RUN=no

We just need AFPD – ATALKD is for pre OSX Systems and PAPD is for printer services.
 

AppleVolumes.default
/YOURPOOLNAME/timeMachineFolder "TimeMachine" allow:@staff cnidscheme:cdb options:usedots,

 

tm, invisibledots,upriv perm:0770

the first entry is the path in the filesystem on the Opensolaris System, the Second one inside the hyphens "The Name" displayed in the Finder.
Then the access priviliges, if you want a specific user to have access you can replace "@staff" with your username.
The "tm" option is essential and it is only available in netatalk 2.0.5 and above as this feature is brand new ;-).

If you want your home folders to be accessible to I recommend replacing the standard option

~

with

~ cnidscheme:cdb options:usedots,invisibledots,upriv perm:0770

if you don't want them to be shared via AFP comment that line out

# ~

 

Make netatalk start automatically as a service

Based upon a smf service description I found here, i made a modified one, with all the correct paths for the current netatalk version (2.5) and a current Opensolaris version (~ build 130).

Grab it here : netatalk.xml (for versions < 2.1)    netatalk.xml (for versions >= 2.1)

Install it and enable the service :

svccfg import /path/to/netatalk.xml
svcadm enable netatalk

 

Configure avahi

Avahi is an Implementation of apple's bonjour protocol.
It advertises your computers network services in the network. When correctly configured it helps the Finder to find and display your Computer under "network servers" section in the sidebar
In an standard OpenSolaris install, you already have it installed.

First you want to advertise your servers afp capatibilites :

/etc/avahi/services/afpd.service
<?xml version="1.0" standalone='no'?>
<!DOCTYPE service-group SYSTEM "avahi-service.dtd">
<service-group>
  <name replace-wildcards="yes">%h</name>
  <service>
    <type>_afpovertcp._tcp</type>
    <port>548</port>
    <txt-record>model=TimeCapsule</txt-record>
  </service>
  <service>
    <type>_device-info._tcp</type>
    <port>548</port>
    <txt-record>model=TimeCapsule</txt-record>
  </service>
</service-group>

Then you want to advertise your TimeMachine shares specifically so they can be used and seen from the TimeMachine prefPane and the TimeMachine restore application from the (Snow) Leopard Installer DVD :

/etc/avahi/services/adisk.service
<?xml version="1.0" standalone='no'?>
<!DOCTYPE service-group SYSTEM "avahi-service.dtd">
<service-group>
  <name replace-wildcards="yes">%h</name>
  <service>  
   <type>_adisk._tcp</type>
   <port>9</port>
   <txt-record>sys=waMA=00:1f:c6:ef:e2:20,adVF=0×100</txt-record>
   <txt-record>dk0=adVF=0xa1,adVN=TimeMachine Laptop,adVU=4ed1be04-64a1-4466-a2ed-b8d9ea6780a6</txt-record>
   <txt-record>dk1=adVN=someShare,adVU=54bc0654-c071-4092-b43c-782c1164bd91</txt-record>
  </service>
</service-group>
Just copy this service xml description and modify the share names to your share names in the AppleVolumes.default file, you can use your own UUIDs, these are just random, just make sure they are unique in your network (change a number e.g.)

Another advantage of this is you don't need to set the TMShowUnsupportedNetworkVolumes switch anymore.

 

Make avahi start automatically as a service

svcadm enable multicast
svcadm enable avahi-bridge-dsd

If you have any problems with avahi autodiscovery – I had too. Restarting avahi-bridge does not seem to suffice after making configuration changes. You first have to refresh / restart multicast and then avahi-bridge like this :

svcadm restart multicast
svcadm restart avahi-bridge-dsd

 

References  :

Mac-[Datei|Backup]-Server mit CentOS 5 | reh-anton.de
Apple Time Machine Network Interface Specification
Build your own Linux Time Machine Server | Terry's Tech Blog
Nexenta Project – AFP with TimeMachine – The Nexenta Project

'[Netatalk-devel] Avahi and Time Machine' – MARC

FreeNAS forum • View topic – Time Machine
tek-ops » Blog Archive » AppleTalk on Solaris (AFP)

 

If you have any suggestions, improvements or corrections leave a comment or drop me an email.

4 Responses to “ZFS and Apple TimeMachine – a perfect Team”

  • Thanks Constantin, my pleasure.
    And also thanks for your update on Solaris 11.

    When I get some spare time I will check how it looks on the newest OpenIndiana and hopefully then find the time to write updated tutorials on OI and S11.

    Regards Marco

  • Hi Marco,

    first of all, thanks for your two most excellent tutorials on how to set up Netatalk with Solaris including TimeMachine and Lion support.

    Here are a few extras for Solaris 11 users:
    – Avahi is not needed in Solaris 11, it’s also not supported. Use dns-sd instead to advertise services.
    – Here’s the equivalent command for registering an afpd service:
    dns-sd -R “NetAtalk Server” _afpovertcp._tcp local. 548 model=TimeCapsule &
    dns-sd -R “NetAtalk Server info” _device-info._tcp local. 548 model=TimeCapsule &
    – And here’s the equivalent command for a TimeMachine volume:
    dns-sd -R “TimeMachine Volume” _adisk._tcp local. 9 “sys=waMA=00:1f:c6:ef:e2:20,adVF=0W100” “dk0=adVF=0xa1,adVN=TimeMachine Constantin,adVU=4ed1be04-64a1-4466-a2ed-b8d9ea6780a6” &
    – This is also better because Avahi relies on Dbus and Dbus doesn’t work within zones. With the dns-sd approach, NetATalk also works in zones.
    – On the current Solaris 11 release, only libgcrypt 1.4.5 is shipped, therefore it’s necessary to compile libgcrypt 1.5.0.

    Netatalk is now running within a local zone of my file server and TimeMachine is happily backing up to it.

    Thanks again for your tutorials!

    Constantin

  • This was so helpful, thank you so much!

  • Thanks for posting this! This is the best netatalk/opensolaris guide I’ve seen.

    One change though. Netatalk’s init script is now named netatalk instead of atalk. So the sfm service desc file will need to be modfied. A simple substitution is enough to get it working again.

    I just set this up painlessly on the new Open Indiana 148 build with netatalk 2.1.5



Your comment :
Name *

Email*
(will not be published)

Website