schrodingerscat
Posts: 3
Joined: Sun Aug 10, 2014 7:00 pm

Building a RaspberryPi Time Capsule: The cheap, fast and sim

Sun Aug 10, 2014 7:22 pm

Since the Raspberry Pi hobbyist development board came out, there have been many guides written on how to convert it into an Apple Timemachine compatible device. Although they work, I have found them to be overly complicated for what has to be done http://administeria.com/raspberry-pi-ti ... ne-server/. Also, they require that the Raspberry Pi has a static IP, something that is inconvenient if you want to set up your backup on a new network when you move house, for example. Thankfully, I found one guide on the forums here that offered a simpler solution http://www.raspberrypi.org/forums/viewt ... 36&t=47029. This guide removed much of the un-needed steps from the previous guides. This guide does require that you do the first preliminary backup over the network. For me, with over 300Gb of data to backup, this would have taken over 24 hours to transfer. It is much faster to do the preliminary backup over USB. As such, I have merged the two guides above into one, cheap, fast and simple Raspberry Pi - Time Capsule guide.

Image

Parts list
Required
SD card
Raspberry Pi
3.5mm Portable Harddrive

Optional
USB Wifi dongle
Philips screwdriver
Sharp blade
Mini USB cable
Soldering iron and solder

Setting up the Hard drive
  • Plug your USB into your Macbook.
  • Click on Applications - System Preferences - Time Machine.
  • Tell Time Machine which drive to use for backups by clicking the “Select Backup Disk…” button, selecting your newly plugged in drive, then clicking the “Use for Backup” button.
  • Time Machine will schedule your first backup to start in just two minutes. You will have to wait a while, as this can take a few hours.
  • Unplug the hard drive when done.
Setting up and configuring the Raspberry Pi
  • Download the latest "Raspbian" OS image file for the Raspberry Pi. Dont download the "NOOB" version, as this will require that you use a TV to set it up. We will be using SSH in this guide.
  • Burn the OS image to the Raspberry Pi. If you are using OSX, use "RPi Easy SD card setup" app. This will take about 20min. Dont worry if you get an error saying "Could not eject card" at the end. It should have completed successfully.
  • Put the SD card in the Raspberry Pi. Connect an ethernet cable from the Raspberry Pi to your router. Power up the Raspberry Pi.
  • Log into your router on your internet browser and get the IP address of the Raspberry Pi. You can also get this using a TV connected to the Raspberry Pi.
  • Open a terminal in OSX, and ssh into the raspberry Pi. The password is "raspberry"
  • Update software on the device

    Code: Select all

    $sudo apt-get update 
    $sudo apt-get upgrade 
  • Install the software that we will need. Netatalk is used for creating NFS shares, the others are used for reading the HFS formatted USB drive

    Code: Select all

    $sudo apt-get install netatalk 
    $sudo apt-get install hfsplus hfsutils hfsprogs 
  • Edit the fstab file to automatically mount the usb drive on boot up

    Code: Select all

    $sudo nano /etc/fstab 
  • Add the following lines, then ctrl + c to save and exit. Note: "sda2" was the partition on my USB drive that needed to be mounted. Yours may be sda1. Run "dmesg" to see which one you will have to mount.

    Code: Select all

    /dev/sda2 /mnt/TimeMachine hfsplus rw,force,exec,auto,users 0 3
  • Open up the permissions of the mount directory

    Code: Select all

    $sudo chmod 777 /mnt/TimeMachine
  • Attempt to mount the usb drive:

    Code: Select all

    $sudo mount /dev/sda1 
    If it mounted successfully, try and write to the USB drive using "mkdir /mnt/Timemachine/testDir". Note: if you reboot the Raspberry Pi and the line in the fstab is not correct, the raspberry Pi will not boot up properly again. The easiest way to recover will be to write a new raspbian image to it. Also use the mount command to check that /dev/sda2 is mapped to /mnt/TimeMachine. Make sure that the letters rw are in the same result. This ensures that we have read/write access to the partition.
  • Add the directory to the "Pi" user (the user that you will be logging in from your macbook with)

    Code: Select all

    $sudo chown -R pi /mnt/TimeMachine 
  • Edit the Netatalk config file to share the Timemachine directory

    Code: Select all

    $sudo nano /etc/netatalk/AppleVolumes.default 
  • Add the following line to the end, save and exit.

    Code: Select all

    /mnt/TimeMachine "Time Machine" options:tm 
  • Restart netatalk

    Code: Select all

    $sudo service netatalk restart 
  • Back on your macbook, a share called "raspberrypi" should appear on the left side of your finder window. If not, in finder, click on Go - Connect to server and type "afp://raspberrypi" or "afp://IPADDRESSOFRASPBERRYPI" into the address window. After you press enter, the shared directory should appear.
  • Go into Timemachine again. Remove the previous backup disk. Click on "select disk" and select the raspberry Pi. It will prompt your for a username and password. Use "pi" for the username and "raspberry" for the password.
    Thats it! The macbook should recognise the previous backup and continue from there. After the previous backup over USB, the second backup over wireless should be alot faster.
Enabling wireless on the RaspberryPi Time Capsule (optional)
You can remove the requirement of having an ethernet cable between the router and the Raspberry Pi by plugging in a small usb wifi dongle into the Raspberry Pi and configuring the wireless. I used a Ralink RT5370 from ebay for this. To connect your Raspberry Pi to the wireless network, here are the steps.
Image
  • SSH into the Raspberry Pi over ethernet (see above).
  • Install the WPA wireless tools

    Code: Select all

    sudo apt-get install wpasupplicant wireless-tools 
  • Edit the networking file to use the wpa-supplicant file for wireless configuration

    Code: Select all

    sudo nano /etc/network/interfaces
  • Ensure the wlan0 section uses the following lines:

    Code: Select all

    allow-hotplug wlan0
    iface wlan0 inet manual
    wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf
    iface default inet dhcp
  • Edit the wpa-supplicant file

    Code: Select all

    sudo nano /etc/wpa_supplicant/wpa_supplicant.conf Ensure that it has the following lines
    ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
    update_config=1
    
    network={
            ssid="YourSSID"
            psk="password"
            key_mgmt=WPA-PSK
    }
  • Save the file, disconnect the ethernet cable, and reboot the Raspberry Pi. It should now connect to the wireless network.
Powering the Raspberry Pi off the hard drive (optional)
  • I did not want to have to have a separate power supply for the hard drive and the Raspberry Pi as both would be kept together at all times. As such, I looked into powering the Raspberry Pi off the supply of the hard drive.
  • Using a sharp knife, cut the male, full size usb connector off your mini usb cable, exposing the four wires.
    Tape up the two data lines, we wont need them and we dont want them touching anything. They are normally the green and white wires.
  • Expose around 2mm of the conductor from the 5v (red) and ground (black) wires. Tin them with solder and the soldering iron.
    Dismantle your portable hard drive. Each one will be different. For mine, I had to remove 4 screws from the underside, and slide out the harddrive and controller from one end.
  • Look for the four wires going from the controller to the hard drive. There should be two black, one yellow and one red. We are looking for the 5v wire (red) and either of the ground wires (black). Solder the red and black wires from the USB cable to the points on the controller board that the corresponding hard drive wires are soldered to.
  • Find a way to route the cable out of the portable hard drive caddy. I drilled a small hole with the screwdriver and pulled the usb cable through it. I also tied a knot in the cable on the end inside the caddy so that it would not get pulled out through the hole if it was tugged on.
  • Put everything back together, power up the portable hard drive, and plug in the Raspberry Pi. The raspberry Pi should power up successfully.
Image
Image
Image
Image

If needed, there is more information available on the blog here: http://warrantyvoidifremoved.blogspot.c ... cheap.html

szbence
Posts: 1
Joined: Mon Feb 16, 2015 9:55 am

Re: Building a RaspberryPi Time Capsule: The cheap, fast and

Mon Feb 16, 2015 9:57 am

I tried lots of tutorials, this is the only one that worked. A huge thank you!

strawberrytau
Posts: 67
Joined: Wed May 30, 2012 7:56 am

Re: Building a RaspberryPi Time Capsule: The cheap, fast and

Sat Mar 07, 2015 9:02 am

I found this guide useful when I was setting up my time machine. Thank you!

My current time machine is fairly slow however, it is taking over 24 hours for a 200GB backup. What speeds do you get on your system? Any tips to speed things up?

schrodingerscat
Posts: 3
Joined: Sun Aug 10, 2014 7:00 pm

Re: Building a RaspberryPi Time Capsule: The cheap, fast and

Sat Mar 07, 2015 10:57 am

strawberrytau wrote:I found this guide useful when I was setting up my time machine. Thank you!

My current time machine is fairly slow however, it is taking over 24 hours for a 200GB backup. What speeds do you get on your system? Any tips to speed things up?
It can be very slow over wifi for the first backup. If you can, you could try Ethernet for the first backup. I believe that some people had success by letting the first backup happen over wifi for 20min. Then disconnecting the sub harddrive and plugging it directly into the laptop to complete the backup. You may have to change the permissions on the harddrive though.

strawberrytau
Posts: 67
Joined: Wed May 30, 2012 7:56 am

Re: Building a RaspberryPi Time Capsule: The cheap, fast and

Sat Mar 07, 2015 8:43 pm

Thanks sc.

In the end, it completed ok in the end. I'm curious to see how well this will work, but all is good so far!

yoyellow
Posts: 12
Joined: Mon Mar 11, 2013 10:29 am

Re: Building a RaspberryPi Time Capsule: The cheap, fast and

Sun Mar 08, 2015 1:03 pm

this works, the only downside i found was throughput, backing up more then just a few GB literally takes days..

Bartthbo
Posts: 2
Joined: Mon Mar 14, 2016 3:12 pm

Re: Building a RaspberryPi Time Capsule: The cheap, fast and

Tue Apr 12, 2016 3:55 pm

Thanks fir the tutorial. It works!! Thanks very very much.

ONLY (sorry) one thing.
After starting TimeMachne on my Macbook Air, after preparing the backup there is a message: TimeMachine is unable to complete the backup.
(Het schijfkopiebestand '/Volumes/Time Machine/MacBook Air van Bart.sparsebundle' dat voor de reservekopie wordt gebruikt, kan niet worden aangemaakt (fout (null)).)
I alrede changed the permission for all users to read/write.
This did not solve the problem.

Any idea how to solve this?

Thanks in advance.

Bartthbo
Posts: 2
Joined: Mon Mar 14, 2016 3:12 pm

Re: Building a RaspberryPi Time Capsule: The cheap, fast and

Tue Dec 27, 2016 12:45 am

Thanks for your clear instructions.
I have one problem.

Open TimeMachine on the Macbook air, it shows the TimeMachine on raspberry pi, I can chose this disk, it asks for the username and passw., which i give in correctly, but it does not start.

Executing the following instruction " sudo chmod 777 /mnt/TimeMachine " it says: files system is read only.

The file system is in /media/pi/TimeMachie, Right (octaal) 40777, name of owner :root: group-name: 80. All rights are wit an [x] except the first three. If I try to change one of them I receive the message :files system is read only.

I have tried several possibilities, but non worked.

Could you give me an idea how to solve this?

Thanks in advance.

Kind regards,
Bart

Kavinskyys
Posts: 1
Joined: Sun Apr 02, 2017 11:23 pm

Re: Building a RaspberryPi Time Capsule: The cheap, fast and

Sun Apr 02, 2017 11:26 pm

I have a 1tb disk for a 128 ssd macbook, can i make partition of the disk and use one has time machine and other has hdd?

tphandley
Posts: 1
Joined: Mon Nov 05, 2018 8:11 am

Re: Building a RaspberryPi Time Capsule: The cheap, fast and sim

Mon Nov 05, 2018 8:20 am

I have followed everything to the letter, however when i do:

$sudo chmod 777 /mnt/TimeMachine

I get: chmod: cannot access '/mnt/TimeMachine': No such file or directory

I've tried various different combinations but nothing works, can anyone help?

Return to “Networking and servers”