Authentic Technical Gibberish

A chocolaty technology blog with a gooey center

Category Archives: Linux

Using an Ubuntu Linux Server with Apple’s Time Machine

The Context.

During the period of time I had Leopard running on my Macbook Pro I had an AFP share on my Linux server that functioned as a Time Machine destination.  I can’t recall if it was an update to Leopard or my upgrade to Snow Leopard, but at some point this functionality broke.  I had moved on to Crashplan because it was multi-platform, worked reliably, and met my rather basic requirements.  I did, however, still use Time Machine for full system backups to locally attached disk on a monthly basis.

Along comes a Lion.

I wanted to wait until the dust settled somewhat before I upgraded to Lion because I use my Macbook Pro as a work laptop as well as for personal use.  For major upgrades like this I tend to be grouped into the early majority category on the technology adoption curve.  I wanted to let some of the other folks at Oracle be the early adopters to discover if VPN, Calendaring, Mail, etc work.  Besides I have been in the middle of a 3 week proof of concept and couldn’t really take the risk of something not working.  Now the time has come to upgrade to Lion and I wanted to take a Time Machine backup before I upgraded.

The problem.

Just over a month ago I upgraded my laptop’s hard drive to a 500GB 7200RPM SAMSUNG HM500JJ  (great drive btw).  Since that time I have added a considerable amount of data to the drive and my external hard drive just isn’t going to work out long term.  I wanted a network based solution like I used to have for Time Machine.

The research.

There are many blog entries about this topic out there, but it seems that none of the ones I could find had %100 of the things needed to be successful.  After perusing multiple blogs it seems that this gentlemen has the correct answer, but didn’t show enough of his work.  Steffen probably didn’t show all of his work due to the fact that he is running Gentoo Linux.  Gentoo is a Linux distribution which takes a very FreeBSD type of approach to package management and has the end user compile software packages instead of distributing them in binary form.  My assumption is that many of the C language header files needed for the solution were already present on his system.

The solution.

I had run Gentoo for 5 years on my “Basement Server”, but switched to Ubuntu LTS releases as I needed a distribution that was a lot less bleeding edge.  With children my tolerance for figuring out why my device tree broke (we transitioned to udev!) had lessoned of late.  Listed below are the steps I took to get a working setup for Snow Leopard as well as Lion.

Steps for the Linux Server (BE SURE TO COPY THE ENTIRE LINE AND NOT JUST WHAT YOU SEE)

  • Make sure the following packages are installed:

Runtime Packages:

apt-get install libavahi-client3 libdb4.8 libssl0.9.8 libldap-2.4-2 libacl1 libwrap0 libgcrypt11

Development Packages:

apt-get install libavahi-client-dev libdb4.8-dev libssl-dev libcrack2-dev libldap-2.4-2-dev libacl1-dev libwrap0-dev libgcrypt11-dev
  • Download Netatalk 2.2 into a temp directory.  As luck would have it Netatalk (the software that provides the capability to create network shares that can be used by OS X and more specifically Time Machine) recently released 2.2 which has the AFP protocol capabilities (replay cache) required by Lion.  The downside is that they are not packaged yet for my version of Ubuntu (Ubuntu 10.04.3 LTS (Lucid)) so this won’t be a simple apt-get install.
tar -zxvf netatalk-2.2.0.tar.gz
cd netatalk-2.2.0
./configure --enable-debian --enable-zeroconf

The output should look like this:

Configure summary:
 Install style:
 debian
 AFP:
 AFP 3.x calls activated:
 Extended Attributes: ad | sys
 CNID:
 backends:  dbd last tdb
 UAMS:
 DHX     ( SHADOW)
 DHX2    ( SHADOW)
 RANDNUM ( SHADOW)
 passwd  ( SHADOW)
 guest
 Options:
 DDP (AppleTalk) support: no
 CUPS support:            no
 SLP support:             no
 Zeroconf support:        yes
 tcp wrapper support:     yes
 quota support:           yes
 admin group support:     yes
 valid shell check:       yes
 cracklib support:        no
 dropbox kludge:          no
 force volume uid/gid:    no
 Apple 2 boot support:    no
 ACL support:             yes
  • Now build netatalk and install it
make

make install
  • Create a user and group for the Time Machine share.  I used the tm group and tm user.
groupadd -g <PICK AN ID> tm
useradd -g <GROUP ID USED IN PREVIOUS STEP> -u <PICK AN ID> -d <HOME DIR> -m -s /bin/false tm
  • Pick some directory that you want to use to put your Time Machine backups and change the “/data/TimeMachine” value in the AppleVolumes.default file to the location you selected and fill in with a valid username.
vi /usr/local/etc/netatalk/AppleVolumes.default
# This file looks empty when viewed with "vi".  In fact, there is one
...
# The "~" below indicates that Home directories are visible by default.
# If you do not wish to have people accessing their Home directories,
# please put a pound sign in front of the tilde or delete it.
~/ "$u" cnidscheme:dbd options:usedots,upriv
/data/TimeMachine "$u Backup" allow:<USER CREATED IN PREVIOUS STEP> cnidscheme:dbd options:usedots,upriv,tm

# End of File
  • Now edit the afpd.conf file
vi /usr/local/etc/netatalk/afpd.conf

#
# CONFIGURATION FOR AFPD
#
...
# default:
- -udp -noddp -uamlist uams_randnum.so,uams_dhx.so,uams_dhx2.so -nosavepassword
  • Now create a file called netatalk.conf and add the following.
vi /usr/local/etc/netatalk/netatalk.conf
# Netatalk configuration

#########################################################################
# Global configuration
#########################################################################

#### machine's AFPserver/AppleTalk name.
ATALK_NAME=`echo ${HOSTNAME}|cut -d. -f1`

#### server (unix) and legacy client (<= Mac OS 9) charsets
ATALK_UNIX_CHARSET='LOCALE'
ATALK_MAC_CHARSET='MAC_ROMAN'

#### Don't Edit. export the charsets, read form ENV by apps
export ATALK_UNIX_CHARSET
export ATALK_MAC_CHARSET

#########################################################################
# AFP specific configuration
#########################################################################

#### Set which daemons to run.
#### If you use AFP file server, run both cnid_metad and afpd.
CNID_METAD_RUN=yes
AFPD_RUN=yes

#### maximum number of clients that can connect:
AFPD_MAX_CLIENTS=20

#### UAMs (User Authentication Modules)
#### available options: uams_dhx.so, uams_dhx2.so, uams_guest.so,
####                    uams_clrtxt.so(legacy), uams_randnum.so(legacy)
AFPD_UAMLIST="-U uams_dhx.so,uams_dhx2.so"

#### Set the id of the guest user when using uams_guest.so
AFPD_GUEST=nobody

#### config for cnid_metad. Default log config:
CNID_CONFIG="-l log_note"

#########################################################################
# AppleTalk specific configuration (legacy)
#########################################################################

#### Set which legacy daemons to run.
#### If you need AppleTalk, run atalkd.
#### papd, timelord and a2boot are dependent upon atalkd.
ATALKD_RUN=no
PAPD_RUN=no
TIMELORD_RUN=no
A2BOOT_RUN=no

#### Control whether the daemons are started in the background.
#### If it is dissatisfied that legacy atalkd starts slowly, set "yes".
ATALK_BGROUND=no

#### Set the AppleTalk Zone name.
#### NOTE: if your zone has spaces in it, you're better off specifying
####       it in afpd.conf
ATALK_ZONE=@AFP
  • Now start up the service.
/etc/init.d/netatalk start
  • To have the service start when the Linux server starts
update-rc.d netatalk defaults

Steps for the OS X Client

  • Start Finder on OS X.  You should see output similar to the screenshot below.  If you cannot see the Linux server then you probably are on a different subnet.  Connect to the server manually (see below) if this is the case.

  •  Manual Connection: Replace “columbus.ohio” with your Linux server name.

  • Now open up Terminal and run the commands below.  This will create the sparse bundle disk image necessary for Time Machine and name it appropriately.  The last command tells OS X that your volume is “Really Nice“.
cd /Volumes/<YOUR VOLUME NAME FOR TIME MACHINE>/
hdiutil create -size <HOW MUCH SIZE YOU NEED IN GB>g -fs HFS+J -volname "Time Machine" `grep -A1 LocalHostName /Library/Preferences/SystemConfiguration/preferences.plist | tail -n1 | awk 'BEGIN { FS = "|" } ; { print $2 }'`_`ifconfig en0 | grep ether | awk 'BEGIN { FS = ":" } ; {print $1$2$3$4$5$6}' | awk {'print $2'}`.sparsebundle
defaults write com.apple.systempreferences TMShowUnsupportedNetworkVolumes 1
  • Configure Time Machine to use new AFS share!

Note: The author has tested file restores using this configuration and they do work fine for me.  The author however does NOT guarantee nor does he claim that this will work for your particular setup.  Finally the author does not guarantee implicitly or explicitly that your data will be safe using the steps mentioned in this blog.

Advertisements