Since getting my Raspberry Pi I have installed a few different operating systems and had a good little mess about. One great use I have found for it is plugging in external drives and utilising it as a Time Machine / Time Capsule backup device for my Mac’s. At such a low price point with a 2Tb drive you can have a working time capsule for under £100! Certainly an attractice prospect for backups!
(This little HOWTO assumes you are running Raspbian)
There are a few steps you need to take in order to get this working, as you will need the Raspberry Pi to support HFS+ as well as running AFP to enable Time Machine.
To enable HFS+ you should install the following
sudo apt-get install hfsplus hfsutils hfsprogs
This will install the necessary packages to mount the HFS+ formatted drive.
Getting the drive to mount as read/write can be achieved by the following command
mount -o force /dev/sdx /mnt/blabla
If the drive doesn’t mount try running a fsck
fsck.hfsplus -f /dev/sdaX (change X to your appropriate drive)
Hopefully this should see your HFS+ drive mounted under raspbian. Now all we need to do is share the drive over AFP and enable Time Machine.
AFP + Time Machine
We need to install a few packages before we can move onto installing AFP support, as netatalk requires a DB as well as encryption.
sudo apt-get install avahi-daemon libavahi-client-dev libdb5.3-dev db-util db5.3-util libgcrypt11 libgcrypt11-dev
Once all dependencies are installed download the latest source code of netatalk (At the time of this HOWTO it was Netatalk 3.0). After unzipping build with the following commands
./configure --with-init-style=debian --with-zeroconf
Now we should have a working install of netatalk which gives us AFP support for the drives we mounted using HFS+. All that is left is to configure afp.conf and start netatalk as a service.
afp.conf is located in /user/local/etc/
Open this file and edit as appropriate by following the instructions at netatalk. However for a simple get started setup the following will give you a drive shared to be used as a Time Machine backup.
; Global server settings
uam list = uams_guest.so
[Time Machine Raspberry]
path = /mnt/test
time machine = yes
With everything configured all that is left to do is run netatalk and your Time Machine backup will appear in the finder under OS X.
This is a very rough guide on how to get everything running under raspbian but hopefully it will providers a jumping off point for further research in order to fine tune the setup to exactly how you want it.
17 thoughts on “Raspberry Pi, Raspbian, HFS+, AFP and Time Machine”
For anyone using some copy & paste to get this done…
The first dashes in the configure line
./configure –with-init-style=debian –with-zeroconf
break the configure command, make sure you change them to actual dashes.
There is also a few ‘Machone’ typos.
Anyway, thanks for the info.
Cheers for pointing that out. I corrected the typos and will have a fiddle with the formatting.
UPDATE = Corrected the dashes now, that was my bad for not using the code tag
This is very helpful. The other examples around on the interwebs in seem to use Netatalk 2.x. Version 3.x has tidied up the config files and removed the need for ‘defaults write allowNetworkTimeMachine’ on the client, it’s great to see another way to do it.
You may want to steal the avahi service XML from http://buffalo.nas-central.org/wiki/Time_Machine_&_Time_Capsule_support_on_your_LinkStation
It turns the Pi into a Time Capsule in the Finder sidebar. I think I prefer “model=Xserve” more 🙂
The majority of the information I found on the net was for Netatalk 2.x thats why I decided to write this.
I am certainly no expert when it comes to Linux so I just threw this together giving a few pointers for people to add on to.
That XML file is a nice addition, cheers!
I followed this guide and it worked for me with a few changes:
My afp.conf is located in /usr/local/etc and I changed it to this:
; Netatalk 3.x configuration file
; Global server settings
uam list = uams_guest.so, uams_dhx.so, uams_dhx2.so,
[Time Machine Raspberry]
path = /media/250GB
time machine = yes
I created a new user on my RPi named “timemachine” and ran the command “sudo chown timemachine /media/250GB” .
I edited /etc/avahi/services/afpd.service based on http://www.ubuntugeek.com/getting-timemachine-to-work-under-ubuntu-10-04-lts-os-x-lion.html (which looks like droid’s) to be:
Now I need to get the drive to mount automatically on start up and make sure Netatalk is also doing the same. This took me two days to get working due to my own errors and general lack of knowledge so I may have done something else and forgotten about it or not needed to make one or more of my changes 🙂 Thanks for writing this up!
Thanks for submitting the changes you made!
I too had an issue with netatalk starting as a service, I did get it to work but I basically tried so many different ways i am not sure which worked. I think I put something together using this
For what it’s worth, I also followed another guide to setup CUPS to share a USB printer. It means you can use Airprint from iOS too. Note the comments on the site, the latest CUPS has a mDNS server built in, so you don’t need to do the avahi service setup.
Thanks for the post;
Ive been unable to write to my usb drive and would love some help. Running most current raspbian release. Drive is formatted mac os extended. Have installed the recommended packages. Using your force mount able to mount drive which I can see when I run df -h from command line. When I go to my Mac and attempt to copy a file to directory where my drive is mounted, after mac finder asks for my mac username and password I get an error message saying “The operation can’t be completed because you don’t have permission to access some of the items.”
I’ve rebooted the ras pi, unmounted and remounted drive. Any suggestions would be appreciated. Thanks.
See if you can create a file in the mounted disk when logged in via ssh. I suspect it’s the permissions on the disk. It could be that the user you are logging in with AFP doesn’t have write permissions.
I think I did…
sudo mkdir -m 777 /media/DISK
sudo chown pi:pi /media/DISK
to make Pi the owner of the directory.
I’m unsure if it would be cleaner to set it in fstab so the disk is mounted for the correct user.
The AFP permissions would be set in the afp.conf, but I think the [Time machine] option takes care of that (man afp.conf).
Thanks, droid. It was a permissions issue. I brushed up on permissions in linux and got it working.
Thanks for the instructions. Just spend most of the evening trying to get it working with 3.0.1 (latest at moment) but could not connect at all.
Removed netatalk and re-tried using 3.0 and works fine now! Not sure where the problem lies with 3.0.1, maybe a subtle config setting change?
Remember a newline in the end of afp.conf
I was setting up netatalk with two Raspberry Pis. One worked, one didn’t. The second simply didn’t show up on my Mac. Found out that pressing enter after “time machine = yes” made all the difference.
Restart the service with “sudo service netatalk restart”
Strangely, my external USB Drive (MBR, 1 partition, HFS+) is mounted automatically in read only following the steps above, and I can not remount it read write. Any idea ?
pi@raspbmc:~$ sudo mount
/dev/mmcblk0p2 on / type ext4 (rw,noatime)
proc on /proc type proc (rw)
devpts on /dev/pts type devpts (rw,noexec,nosuid,relatime,gid=5,mode=620)
/dev/mmcblk0p1 on /boot type vfat (rw)
/dev/sda1 on /media/TimeCapsule type hfsplus (ro,nosuid,nodev,uhelper=udisks)
pi@raspbmc:~$ sudo mount -n -o remount,rw /media/TimeCapsule
mount: /media/TimeCapsule not mounted or bad option
How can you get this to work with an encrypted (FileVault) volume?
I’ve just written a guide for running all this under time machine:
In case someone’s interested, I’ve started building netatalk-3 .debs: https://github.com/thpani/netatalk-armhf/releases