I’ve been wanting to do something useful with my Raspberry Pi lately, so I decided to make a network-connected backup drive for use with Time Machine on my Mac. There are lots of online articles that explain the process, though many seem full of extraneous steps. In this post, I’ll outline a minimalist approach to creating your own Time Capsule from a Raspberry Pi.

We’ll be on the command line almost exclusively, so crack those knuckles and get ready to hack!

What you’ll need


Prepare your Pi

  1. Follow the installation instructions over at raspberrypi.org to get your favorite Linux distribution installed onto your microSD card. This guide was written using Raspbian Jessie Lite, which is command-line only.

  2. On your Pi, run:

    $ sudo raspi-config

    If you’re not using a USB keyboard and monitor connected to the Pi, you can connect the Pi to your computer with an ethernet cable and remote into it with the following command from your computer:

    $ ssh pi@raspberrypi.local
  3. Once in raspi-config:

    • Expand the file system
    • Enable auto-login to the console on boot
    • Disable waiting for network on boot
    • Configure localization settings
  4. After confirming settings and rebooting, configure your wifi per the instructions over at raspberrypi.org, then reboot your Pi to ensure it worked (sudo reboot).

    After this, you should be able to disconnect the ethernet cable if you used one, as long as your computer is on the same wifi network as your Pi.

  5. Then, just to keep things up-to-date, run:

    $ sudo apt-get update
    $ sudo apt-get dist-upgrade

Prepare your drive

Before we dive into preparing your drive, I’ll share my experience regarding drive formats. Since I had used my drive previously with a Mac, it was formatted as HFS+ Journaled. Though a quick Google search can tell you how to get your Pi to work with the HFS+ file system, I did run into trouble with journaling being enabled on HFS+. Be forewarned that you may need to disable journaling with HFS+ (a quick Google search can tell you how), something you may not be willing to do, due to the benefits it provides to data integrity during a sudden power loss.

Even if your drive is HFS+ with journaling disabled, I found that an HFS+ drive will auto-mount to read-only after a sudden power loss, requiring the drive to be repaired via fsck before it can be used to backup your computer again. Instead of dealing with some of these headaches, I opted to simply reformat my drive as EXT4, which has its own journaling feature. Note that EXT4 is not as readily readable by macOS as HFS+ or ExFAT, should you ever need to plug the drive directly into your computer, but this seems like something third-party drivers can likely solve. Because the drive will be read over the network and not by plugging it into my Mac directly, it’s not something I’m concerned about.

Partitioning and formatting is a large topic of its own, so it’s not covered in detail in this post. That said, if you have a drive that is empty or one you’re willing to erase, I’ll show you how to format it to EXT4 in a later step.

Either way, let’s continue…

  1. If you’re not using a powered USB hub to connect your drive, chances are it draws too much power from your Pi’s USB ports alone. Thankfully, it’s possible to increase the max USB current from 600mA to 1.2A, which was enough to power my Seagate portable HDD without the need for a powered hub. You can skip this step if you’re using a powered hub. Otherwise, run:

    $ sudo nano /boot/config.txt

    then add this to the end:


    Then reboot.

  2. Next, plug your drive into your Pi and run:

    $ sudo fdisk -l

    This will list your attached devices. Take note of the device name of your backup drive (e.g. /dev/sda), as well as the name of the partition you intend to use (e.g. /dev/sda1).

    As promised, if you want to start fresh, you can format a drive to have a single EXT4 partition with:

    $ sudo parted /dev/sda mklabel gpt
    $ sudo parted -a optimal /dev/sda mkpart Primary 0% 100%
    $ sudo mkfs.ext4 /dev/sda1

    (Adjusting sda and sda1 to correspond to your device name)

Mount your drive

  1. List the UUIDs for your connected drives and note the UUID for your backup partition:

    $ sudo blkid
    /dev/mmcblk0: PTUUID="8b3ddfa2" PTTYPE="dos"
    /dev/mmcblk0p1: SEC_TYPE="msdos" LABEL="boot" UUID="70F7-FA1D" TYPE="vfat" PARTUUID="8b3ddfa2-01"
    /dev/mmcblk0p2: UUID="3598ef8e-09be-47ef-9d01-f24cf61dff1d" TYPE="ext4" PARTUUID="8b3ddfa2-02"
    /dev/sda1: UUID="7820c21e-b91f-449e-8752-feb34c226021" TYPE="ext4" PARTLABEL="Primary" PARTUUID="baf78609-f6ac-49cd-8704-c9a3739d03e4"

    (Our example uses line 4)

  2. Now, create a mount point:

    $ sudo mkdir -p /media/time_machine
    $ sudo chmod 777 /media/time_machine
  3. Then, to auto-mount on boot, edit your Pi’s fstab file:

    $ sudo nano /etc/fstab

    and add this to the end, substituting your partition’s UUID from step 1 above:

    UUID=7820c21e-b91f-449e-8752-feb34c226021  /media/time_machine  ext4  defaults  0  2

    Then reboot.

    If you ever reformat the drive, the UUID could change, and the fstab file will need to be updated.

Configure power saving

  1. If you’re using a disc drive (vs. solid state), you probably want it to spin down when it’s idle to save power. To do this, we first need to install hdparm:

    $ sudo apt-get install hdparm
  2. Before configuring hdparm, we’ll need the drive’s ID (which is different from the partition UUID retrieved earlier):

    $ sudo ls -la /dev/disk/by-id
    lrwxrwxrwx 1 root root  9 Oct 15 15:53 ata-ST9500325AS_6VED425F -> ../../sda
    lrwxrwxrwx 1 root root 10 Oct 15 15:53 ata-ST9500325AS_6VED425F-part1 -> ../../sda1
    lrwxrwxrwx 1 root root 13 Oct 15 15:53 mmc-SU04G_0x1165d4c7 -> ../../mmcblk0
    lrwxrwxrwx 1 root root 15 Oct 15 15:53 mmc-SU04G_0x1165d4c7-part1 -> ../../mmcblk0p1
    lrwxrwxrwx 1 root root 15 Oct 15 15:53 mmc-SU04G_0x1165d4c7-part2 -> ../../mmcblk0p2
    lrwxrwxrwx 1 root root  9 Oct 15 15:53 wwn-0x5000c5002b19e5c8 -> ../../sda
    lrwxrwxrwx 1 root root 10 Oct 15 15:53 wwn-0x5000c5002b19e5c8-part1 -> ../../sda1
    • Note that we’ll take the ID for the entire drive (/dev/sda) rather than a partition (/dev/sda1)
    • You might notice multiple IDs for the same device, as seen above. I’m not an expert, but from what I’ve read, it shouldn’t matter which you use.
  3. Now that we’ve got our drive’s ID, we can configure hdparm:

    $ sudo nano /etc/hdparm.conf

    Add the following to the end, substituting your drive’s ID:

    /dev/disk/by-id/ata-ST9500325AS_6VED425F {
        spindown_time = 60

    Then reboot.

    This setting will spin down the drive after 5 minutes of idling. The value for spindown_time is a bit strange, as it’s specified in multiples of 5 seconds (but only when the value is between 1 and 240). For more information, see this helpful post.

Make your drive visible

  1. To make your drive visible on your network, your Pi needs to support AFP (Apple Filing Protocol). Thankfully, there’s an “apt-get” for that:

    $ sudo apt-get install netatalk

    As of this writing, version 2.2.5 was installed. Other online tutorials will explain how to build and configure a version 3 variant, but I found the way described here to be much more straightforward.

  2. Then edit AppleVolumes.default:

    $ sudo nano /etc/netatalk/AppleVolumes.default

    and add this to the end:

    /media/time_machine  "Time Capsule"  options:tm
  3. Finally, restart the netatalk service (or reboot your Pi):

    $ sudo service netatalk restart


Once you’ve completed these steps, you should be able to select your new Time Capsule from your Time Machine’s preferences. Just enter your Pi’s credentials when prompted and you’re ready for automatic wireless backups!

backup raspberry pi time capsule time machine