Mac|Life

DIY Time Capsule

Learn to build an inexpensiv­e network-connected drive to back up your Macs using Time Machine

- words: Lucy Hattersley

Network-connected drives don’t come cheap, but with a Raspberry Pi 2 and an external hard drive, you can build an inexpensiv­e Mac backup solution.

>>> Raspberry Pi is a tiny, flexible, and inexpensiv­e computer that can be used for many fun and practical projects. We’re going to make a Time Capsule equivalent using a Raspberry Pi 2 and an external hard drive. You’ll need to download and install some extra software for the Pi cso it can use a Mac-formatted drive and talk to Time Machine on your Mac. (Note, because this is an unofficial Time Capsule system, you shouldn’t rely on it as your only backup.) If you’ve only just got a Raspberry Pi, you’ll need to put an OS on it; follow the steps on p53, then return here.

With your hardware ready and Raspbian’s desktop in front of you, choose Menu > Accessorie­s > Terminal (similar to the Mac app of the same name). At its command line, enter sudo apt-get update && sudo apt-get upgrade to make sure your installati­on is up to date. You’ll see lines of text filling Terminal’s window. When the process finishes and the scrolling stops, you’ll see another colored line of text that ends with a $. Now we can get down to business with the various bits of software. Portions of what follows are based on Caleb Woods’ tutorial at bit.ly/mlcwtc.

Get the Pi to read a Mac disk

First, download the tools Raspbian needs to work with Apple-formatted drives.

Still in Terminal on the Pi, enter sudo apt-get --assume-yes install hfsprogs hfsutils

hfsplus to download them. To check where the drive is connected in the system, enter sudo /sbin/parted then, at this tool’s own command line, enter

print to get info about your external drive. The command’s output will include a line that starts with “Disk /dev/sda” followed by the drive’s capacity. Below that, a table should have two rows: find the one that refers to the partition named “Time Machine” on the external drive – all being well it should be 2. This tells us /dev/sda2 is the location of the Time Machine partition. Enter quit.

We need Raspbian to mount the drive so we can use it. First, create a folder by entering sudo mkdir -p /media/time_

machine. The last parameter there represents where the partition’s file system will be mounted, much like the /Volumes folder in OS X.

Next we’ll use a text editor, Nano, to edit a file that contains a list of all file systems we want the system to mount at startup. Enter sudo nano /etc/fstab. This file will contains several entries already. Below them (but above the lines starting with a # symbol), add the following text as a single line. (Where you see a gap in the text below, press the † key exactly once, rather than the Spacebar.) /dev/sda2 /media/time_machine hfsplus force,rw,user,auto 0 0

Press ≈+o and then ® to save your changes to the file, then press ≈+x to quit Nano. Now you’re back at the command line, enter sudo mount -a to ensure the partition is mounted. Get the Mac and the Pi talking Next we’ll install Netatalk. We need version 3.0 or higher, which we’ll build from source code. Open the Epiphany web browser from the left end of Raspbian’s Task Bar and go to netatalk.

sourceforg­e.net. Under “current releases” on the left, click the link to download the latest stable version (3.1.8 at the time of writing) in gzip format. It will be saved to your Downloads folder, and the Xarchiver app will open to show you its contents. Right-click the file within and choose Extract (if rightclick­ing doesn’t work with your mouse, select the file, then choose Action > Extract). Put it in your Downloads folder (it should already be chosen for you). We need to install the packages listed

at bit.ly/mlntpackag­es. If you’re new to this, it’s safest to install one at a time. For each of the required packages, type

sudo apt-get --assume-yes install into Terminal, followed by a space, then the the name of a package, then ® .

Enter cd ~/Downloads/netatalk-3.1.8 To configure Netatalk’s installer, enter the following text – every double hyphen should be preceded by a space, and every line that ends with a hyphen below has no space after it.

./configure --with-init-style=debiansyst­emd --without-libevent --without-tdb --with-cracklib --enable-krbV-uam --withpam-confdir=/etc/pam.d --with-dbussyscon­f-dir=/etc/dbus-1/system.d --withtracke­r-pkgconfig-version=1.0

You’ll see a summary when this process completes. The next few commands take a while to complete. Enter sudo make. When it’s done, enter

sudo make install to run the installer. When this finishes, verify Netatalk installed correctly by entering afpd -V. The first line of the response should be “afpd 3.1.8 - Apple Filing Protocol (AFP) daemon of Netatalk” To start the software, enter sudo

service avahi-daemon start, followed by sudo service netatalk start. Neither command should return output, but you should see “raspberryp­i” appear under Shared in Finder’s sidebar on your Mac.

You’ll want Netatalk to start at login on the Pi. Enter sudo nano ~/.bashrc and add the two commands from the previous paragraph on new lines at the end of the file. Press ≈+o and then ® to save the file, then ≈+x to quit Nano. Enter sudo nano /etc/nsswitch.conf. Look for the line starting “hosts: files mdns4_minimal” Add a space to its end, then append mdns4 mdns. Save changes and quit Nano with ≈+x.

Now enter sudo nano /etc/avahi/ services/afpd.service, and add the following into that file:

<?xml version="1.0" standalone='no'?>< !--*-nxml-*-->

<!DOCTYPE service-group SYS TEM "avahi-service.dtd"> <service-group>

<name replacewil­dcards="yes">%h</name> <service> <type>_afpovertcp._tcp</type> <port>548</port> </service> <service> <type>_device-info._tcp</type> <port>0</port> <txt-record>model=TimeCapsul­e </txt-record> </service> </service-group> Save and quit, then enter sudo nano /usr/local/etc/afp.conf and under [Global] in that file add mimic model = TimeCapsul­e6,106. Also, append this to the end of the file: [Time Machine 3TB] path = /media/time_machine time machine = yes

Save and quit, then restart your Pi. In Finder on your Mac, under Shared in the sidebar, connect to the Time Machine partition on the Pi using “pi” as the username and “raspberry” as the password. Finally, connect Time Machine to your Pi within the app on your Mac.

 ??  ?? Combining a Raspberry Pi with a hard drive is much cheaper than buying a Time Capsule.
Combining a Raspberry Pi with a hard drive is much cheaper than buying a Time Capsule.
 ??  ??

Newspapers in English

Newspapers from Australia