Tuesday, December 25, 2012

Raspberry Pi, Raspbmc, HFS+, AFP and Time Machine

So last week I got myself a Raspberry PI. The idea was - and still is - to turn it into a little media server for the family (ahem, me). One thing that I want it to do as well is a backup server for all the gadgets in the house. First up, my wife's Mac with OS 10.7.4.

First, I formatted a USB drive on her Mac following Apple's support pages.

Like I said, I installed Raspbmc on the PI. This is a pretty naked Debian system. I roughly followed the instructions on Simon's blog to install HFS+ Apple file system support:

sudo apt-get install hfsplus hfsutils hfsprogs
sudo mkdir /media/timemachine
sudo mount -o force /dev/sdb2 /media/timemachine
sudo adduser timemachine
sudo chown timemachine /media/timemachine
However, compiling netatalk 3.0.1 for which there is no Debian compiled package yet was a little harder since I first needed to install the build tools, compiler etc.

sudo apt-get install make gcc binutils 

Then following Simon again with 

sudo apt-get install avahi-daemon libavahi-client-dev libdb5.3-dev db-util db5.3-util libgcrypt11 libgcrypt11-dev

I retrieved the netatalk sources directly from the SourceForge web site and copied them over to the Pi with scp. Then I unpacked them and installed them the standard way:

./configure --with-init-style=debian --with-zeroconfmake install
sudo make install
I configured the afp service like so
sudo nano /usr/local/etc/afp.conf
;; Netatalk 3.x configuration file;

; Global server settings
uam list = uams_guest.so, uams_dhx.so, uams_dhx2.so
; [Homes]basedir regex = /home
; [My AFP Volume]; path = /path/to/volume
[Time Machine Raspberry]
path = /media/timemachine 
time machine = yes
Then I needed to restart the netatalk and avahi services:

sudo /etc/init.d/netatalk restart
sudo service avahi-daemon reload
Then I needed to prepare the Mac, for which I followed this page (the stuff at the top of the page I didn't do). 

What's needed now is the auto-mount of the USB drive!  Change 05/13: Raspbmc now automounts the drives, I believe with improved udev rules.

I did have to go through the above rigmarole again, after the raspbmc OS update, and found that the timemachine drive would now auto-mount, but only read-only. After some hours of research :-), I found the solution: Take the drive off the pi, plug it into the Mac and repair it with the disk utility. Also, I think somehow Journaling was switched back on, so I turned it back off (For the option to appear in the "Edit" ("Ablage" in German) menu, you have to first press the "Alt" key, then select the menu.) This didn't work, so I used the cmd-line diskutil tool to do it:

sudo diskutil unmount /Volumes/timemachine

sudo diskutil disableJournal force /dev/disk2s2

(I knew the disk2s2 bit from running diskutil list)

'via Blog this'