Time Capsule / Time Machine through Raspberry Pi

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 upgrade
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 chmod 777 /mnt/TimeMachine
sudo echo "/dev/sda<device number> /mnt/TimeMachine auto defaults 0 2" >> /etc/fstab
sudo mount /dev/sda<device number>

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. If you get permission errors, run sudo chmod 777 /mnt/TimeMachine again on the PI. I don’t know yet why, but this seems to get lost on reboot.

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 –

13 Replies to “Time Capsule / Time Machine through Raspberry Pi”

  1. 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. 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. 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.

    1. 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.

  3. 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. 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)

  4. 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

Leave a Reply

Your email address will not be published.