I’ve followed multiple tutorials on how to setup time capsule through raspberry pi. There’s one that’s by far the simplest & it works: https://www.raspberrypi.org/forums/viewtopic.php?f=36&t=47029

In fact, the others are so much more complicated that I thought this wouldn’t work and tried it last: What a mistake.

Here’s a short re-write with a few minor changes, also covering the formatting of the storage drive.

## Format the Storage Drive

On the PI:

Run lsblk -o KNAME,TYPE,SIZE,MODEL in order to find your drive. Then run:

mkfs.ext4 /dev/sda

Replace sda with the corresponding drive.

In case you want a partitioned drive: Tutorial: http://askubuntu.com/questions/517354/terminal-method-of-formatting-storage-drive

## Getting the required Packages

The communication between Mac and PI will go through netatalk:

sudo apt-get update
sudo apt-get install netatalk

## Setting up

Find the device number using lsblk -o KNAME,TYPE,SIZE,MODEL as above, then:

sudo mkdir /mnt/TimeMachine
sudo echo "/dev/sda<device number> /mnt/TimeMachine auto defaults 0 2" >> /etc/fstab
sudo mount /dev/sda<device number>
sudo chmod 777 /mnt/TimeMachine

then

sudo echo "/mnt/TimeMachine \"Time Machine\" options:tm" >> /etc/netatalk/AppleVolumes.default
sudo service netatalk restart

Now restart the pi.

## Select the Disk on the Mac

Now you’ll automatically discover the new Disk in the Time Machine Preferences.

Note: If you get an error like

The backup disk image “/Volumes/backups-1/<your computer name>.sparsebundle” could not be created

it’s probably because you plugged out the drive from the running pi and then plugged it back in. Just restart the pi and it should work again. It also might be necessary to run the following command in the terminal first:

defaults write com.apple.systempreferences TMShowUnsupportedNetworkVolumes 1

– the end –

## Join the Conversation

1. Bruno Teles says:

Any way of making a partition of a hdd, one for time machine and other for data trough pi ? I have follow so many tutorials and none talks about this

2. John O. says:

I am trying this now. When running

sudo echo “/dev/sda /mnt/TimeMachine auto defaults 0 2” >> /etc/fstab

getting -bash: /etc/fstab: Permission denied

Any advice? Also wondering this this will allow two Macs to back up to the same Time Machine, like Time Capsule.

1. bersling says:

Hi, about the error I don’t know. But I know that it’s possible to run with multiple macs.

2. Kevin says:

I had this issue, too. Just open the file “/etc/fstab” with a text editor (emacs, etc.) and enter the line in quotes to the end of the file manually.

3. Tinoargentino says:

I tried using nano to edit /etc/fstab
it worked that far, though I couldn’t make the whole thing work
Maybe you can make it work

try this:
sudo nano /etc/fstab

and then add to the file the line
sudo echo “/dev/sda /mnt/TimeMachine auto defaults 0 2” >> /etc/fstab

then save and close the editor

Good luck!

3. Florian says:

Well… I think chmod 777 isn’t the best idea. Very, very bad tut.

1. bersling says:

Good point, on my network it’s fine but I don’t know how it is for others. I think the slightly less permissive setup 775 should also work.

4. Chris says:

Will this not crash after a few months, so far all my time machine rpi projects have had some sparsebundle errors that i could not manage to fix

1. bersling says:

I’ve been running it now for roughly 1 year and it works fine so far.

1. Chris says:

I tried doing:
sudo echo “/mnt/TimeMachine \”Time Machine\” options:tm” >> /etc/netatalk/AppleVolumes.default

but it gives me the error: -bash: /etc/netatalk/AppleVolumes.default: Permission denied

I tried adding it manually like this:
/mnt/TimeMachine \”Time Machine\ options:tm

I can not see the device on my mac (also ran the terminal command listed at the bottom of the post)

1. Chris says:

nvm; got it working 😀
Thanks for the tut!

5. Kay says:

Everything is great till
sudo echo “/dev/sda /mnt/TimeMachine

There it says that I don’t have permission to do so.

So I run the command as su
but I think there still has to be an error

6. Kay says:

I can not find my Raspberry on Finder I have to connect manually!

Is there a way or a setting to get its to auto connect?

7. Dustin LaFavre says:

This worked great. Thanks!

8. Patrick says:

The reason the “777” permissions are getting lost on reboot after initial setup is because you set the permissions before you mounted the disk. This sets permissions on your mount point as if it were a standalone directory. When the disk is mounted the owner, group, and permissions of the root of its filesystem take effect and override whatever ownership and permissions were set on the mount point as a standalone directory.

See the following link for an explanation:

https://www.ibm.com/developerworks/community/blogs/brian/entry/managing_filessytem_mount_point_permissions_aix_linux_unix15?lang=en

If you adjust your instructions as follows, you’ll only have to set the permissions once and they’ll survive the reboot:

sudo mkdir /mnt/TimeMachine
sudo echo “/dev/sda /mnt/TimeMachine auto defaults 0 2” >> /etc/fstab
sudo mount -a
sudo chmod 777 /mnt/TimeMachine

The fourth line in the modified instructions, above, (sudo mount -a) attempts to mount everything in /etc/fstab which has the effect of not only mounting the disk to the mount point but does so while testing your /etc/fstab file prior to reboot.

1. bersling says:

Thanks for the hint, I’ve changed that!

9. turo says:

sudo echo “/dev/sda /mnt/TimeMachine auto defaults 0 2” >> /etc/fstab
will not work, change this to:
sudo sh -c “echo /dev/sda /mnt/TimeMachine auto defaults 0 2 >> /etc/fstab”

(The output redirection “>>” has to be done with superuser rights…)

10. Antonio S. Neto says:

This is pretty neat, thank you! I’m not exactly there yet: I can see the drive on Time Machine from the Mac but when I try to select it, after entering my credentials it gives me a warning that I do not have permissions to read/write, even though I did the chmod on the folder and I can see it shows ‘drwxrwxr-x’ for permissions. Any recommendations? Thanks!

1. lorrrris says:

Did you format your drive to ext4 as suggested in the beginning of the tutorial?
My disk was still formatted to HFS+, which can only be mounted read-only under Linux. For this reason also the chmod command did not work and the needed permissions were never set.