optimisme
Posts: 3
Joined: Mon Jan 28, 2013 7:32 pm

Time Capsule setup with Raspberry Pi

Mon Jan 28, 2013 8:15 pm

Hi,

I wasted several hours trying to configure my Raspberry Pi to work as a Time Capsule server from SSH, this is a step by step guide. (I hope this helps someone)

Recomendations:

- Use a micro USB charger with 5Volts and at least 2.1Amps if you want to power the Raspberry Pi with a USB hard drive and a USB Wi-Fi. The "iPad" USB charger with a Micro USB cable works great. With less than 2.1Amps my Pi crashes and loses network connection every now and then.
- Also, do not "live" plug or unplug USB devices, ensure that the Pi is turned off when plugging or unplugging USBs.
- Unmount properly your USB drive before disconnecting the power cable, also remember to type "sudo shutdown now" and wait a while before turning off your Pi (removing the power cable)

Set up the "SD Card" with Mac OSX:

With "Disk Utility" Unmount the partition of the SD card but DO NOT eject the disk.

Using the OSX "Terminal", type the next command to get the USB identifier

Code: Select all

diskutil list
Using the OSX "Terminal", type one command similar to the next one to copy your ".img" file to the SD Card

Code: Select all

sudo dd if=/Users/[b]mark[/b]/Downloads/[b]2012-12-16-wheezy-raspbian.img[/b] of=[b]/dev/disk1[/b] bs=1m
- "mark" is your username
- "2012-12-16-wheezy-raspbian.img" is the ".img" file
- "/dev/disk1" is the SD Card, do not type a partition like "/dev/disk1s1"

Raspberry configuration:

Connect to your PI using SSH from OSX Terminal with: - Where XX.XX.XX.XX is the IP of your PI, you can get this information from your router

Set up various things such as: "expand_rootfs", "change_timezone", "boot_behaviour", "update"...

Code: Select all

sudo raspi-config
Update your PI

Code: Select all

sudo apt-get update
Set up Wi-Fi:

Code: Select all

I am using one D-Link DWA-121 (Version A1). Wireless N 150 Pico that woks "out of the box" without drivers
The easiest way to set up your "wireless" from command line is using "wicd-curses"

Code: Select all

sudo apt-get install wicd wicd-curses
sudo wicd-curses
- Static IP is safer/faster
- Set DNS domain, Search domain and DNS1 with the same value

Check your connection with

Code: Select all

ifconfig
Set up HFS+ Disk mount:

Install "HFS+" support

Code: Select all

sudo apt-get install hfsplus hfsutils hfsprogs
Get the device Name of the drive (I recommend to format it with "TimeCapsule" for this guide)

Code: Select all

sudo blkid
Create a folder to mount the drive

Code: Select all

sudo mkdir /media/TimeCapsule
Create an init file to activate/deactivate TimeCapsule server and disk mount:

Code: Select all

sudo nano /etc/init.d/TimeCapsule
Copy the next code to disk file, changing the "TimeCapsule" text to your USB drive' name

Code: Select all

#!/bin/bash
DNAME="TimeCapsule"
if [ "$(id -u)" != "0" ]; then
        echo "This script must be run as root" 1>&2
        exit 1
fi
case "$1" in	
	start)
        service netatalk stop
        service avahi-daemon stop
        umount -l /media/TimeCapsule
        sudo fsck.hfsplus -f `blkid -L $DNAME`
        mount -t hfsplus -o force `blkid -L $DNAME` /media/TimeCapsule/
        service netatalk start
        service avahi-daemon start
		;;
	stop)
        service netatalk stop
        service avahi-daemon stop
        umount -l /media/TimeCapsule
		;;
	*)
        echo "Usage: /etc/init.d/TimeCapsule {start|stop}"
        exit 1
    ;;
esac
exit 0
Give permissions to the file, and make the init script visible.

Code: Select all

sudo chmod +x /etc/init.d/TimeCapsule
sudo update-rc.d TimeCapsule defaults
sudo reboot
- Wait until you can SSH to the Raspberry again
Mount your "TimeCapsule" drive with the next command "sudo /etc/init.d/TimeCapsule start|stop".
This is to ensure that "netatalk" and "avahi" are not working when the drive is "mounted or unmounted"
Set up "Raspberry PI" as TimeCapsule server:

Install "Netatalk" and "Avahi"

Code: Select all

sudo apt-get install avahi-daemon libavahi-client-dev libdb5.3-dev db-util db5.3-util libgcrypt11 libgcrypt11-dev
wget http://downloads.sourceforge.net/project/netatalk/netatalk/3.0.2/netatalk-3.0.2.tar.bz2
tar -xvf netatalk-3.0.2.tar.bz2
cd netatalk-3.0.2/
./configure --with-init-style=debian --with-zeroconf
make
sudo make install
Open this configuration file

Code: Select all

sudo nano /usr/local/etc/afp.conf
Replace its contents by the following code:

Code: Select all

[Global]
; Global server settings
hostname = TimeCapsule Pi
mimic model = TimeCapsule
log file = /var/log/netatalk.log
log level = default:info

[Data]
; Our Time Machine volume
path = /media/TimeCapsule
cnid scheme = dbd
file perm = 0660
directory perm = 0770
time machine = yes
Open the next configuration file

Code: Select all

sudo nano /etc/avahi/services/timecapsule_afpd.service
Replace its contents by the following code

Code: Select all

<?xml version="1.0" standalone='no'?>
<!DOCTYPE service-group SYSTEM "avahi-service.dtd">
<service-group>
</service-group>
Turn on the "Time Capsule" server, an icon will show up on your OSX finder:

Code: Select all

sudo /etc/init.d/TimeCapsule start
The last configuration will show the "Time Capsule" icon as if it is a real "Time Capsule", it will also hide the "home" folders from Raspberry users. Showing only one icon at Finder instead of "repeating" the connections.
Important! Usage:

To "start or stop" the "Time Capsule server" or to "mount or unmount" the USB drive, use the following commands:

Code: Select all

sudo /etc/init.d/TimeCapsule start
sudo /etc/init.d/TimeCapsule stop

optimisme
Posts: 3
Joined: Mon Jan 28, 2013 7:32 pm

Re: Time Capsule setup with Raspberry Pi

Mon Feb 18, 2013 12:09 am

After some days using Raspberry as a Time Capsule:

- WiFi needs too much energy, I am using just an Ethernet cable.
- I changed "/usr/local/etc/afp.conf" [file perm = 0664] and [directory perm = 0774]
- I created and installed "Pi OS" to a USB partition, SD card is too slow
- Pi is slower than a real Time Capsule, specially when time machine is connecting and "preparing backup..."

Nicolinux
Posts: 1
Joined: Sun Mar 17, 2013 11:26 am

Re: Time Capsule setup with Raspberry Pi

Sun Mar 17, 2013 11:28 am

Thanks for the guide optimise. I just followed it and it works flawlessly. One thing to note (for others) - don't try this on raspbmc because rpi can't handle the load of both - Time Machine and XBMC.

pompor
Posts: 15
Joined: Tue Feb 19, 2013 1:46 pm

Re: Time Capsule setup with Raspberry Pi

Mon Mar 18, 2013 10:07 pm

Hey, i have the following problem:
The Pi doesn´t mount the Disk correctly, he only mounts it as a Read Only Device, if i ssh into my pi and type "mount" he gives me back

Code: Select all

[...]
/dev/sda2 on /media/TimeCapsule type hfsplus (ro,nosuid,nodev,relatime,umask=22,uid=0,gid=0,nls=utf8,uhelper=udisks)
any ideas?
BTW; anything else works fine, i even got the timecapsule on my mac, but i can´t connect (because of the read only state)

pompor
Posts: 15
Joined: Tue Feb 19, 2013 1:46 pm

Re: Time Capsule setup with Raspberry Pi

Tue Mar 26, 2013 11:35 am

Can anyone help me?

wallinleft
Posts: 1
Joined: Sun Mar 31, 2013 2:25 pm

Re: Time Capsule setup with Raspberry Pi

Sun Mar 31, 2013 2:42 pm

Debian doesn't support journaling, so it needs to be turned off for the disk to be writable.

I found instructions for turning journaling off using disk utility here: http://support.apple.com/kb/ht2355, but when I tried doing it on the disk I'm using for Time Machine, I got an error saying that I couldn't turn off journaling.

I didn't investigate further since I've ordered a new drive for use with my raspberry pi-powered time capsule, so I'll be sure to format it with journaling turned off.

elCharon
Posts: 1
Joined: Sat Apr 20, 2013 8:03 am

Re: Time Capsule setup with Raspberry Pi

Sat Apr 20, 2013 8:09 am

Thanx for the good instruction. I got a TimeCapsule Pi.

The Capsule appears in the Drives Section but i can´t activate it, because every Servername + Password do not work.

I tried "root" and "pi". Every time it ends with the Mac "error"-shake. :oops:

Can anyone help.

kumar
Posts: 3
Joined: Mon Apr 15, 2013 6:00 am

Re: Time Capsule setup with Raspberry Pi

Sun Apr 21, 2013 5:45 am

optimisme wrote:Hi,

I wasted several hours trying to configure my Raspberry Pi to work as a Time Capsule server from SSH, this is a step by step guide. (I hope this helps someone)
I've handed over the mounting job to /etc/fstab, mounting with hard disk UUID. Does it interfere with your init.d mount/umount specified in this tutorial?

Can't I use netatalk installed from raspian repo or any other repo so that update/upgrade is painless?

I've two hard disks: one I've many movies and other files on it which I am also planning to use as a download location for Pi torrent client(yet to setup - most probably rtorrent or transmission-cli) and another I am planning to use as TimeMachine backup location.

Can I use two hard disk in this manner? How to do it?

Skyaddict
Posts: 3
Joined: Mon Apr 15, 2013 10:59 pm

Re: Time Capsule setup with Raspberry Pi

Tue Apr 23, 2013 8:55 pm

Nicolinux wrote:Thanks for the guide optimise. I just followed it and it works flawlessly. One thing to note (for others) - don't try this on raspbmc because rpi can't handle the load of both - Time Machine and XBMC.
Nicolinux, I've got it running on raspbmc, and it's quite stable. Time machine will backup while a movie is playing with no problem.

Took me a while to get the drive mounting correct so they'd be writable from the Mac (there's one time capsule drive and two ext4's on a powered hub.

It's not the fastest in the game, but it's cheap.

remipou
Posts: 4
Joined: Mon May 20, 2013 6:43 pm

Re: Time Capsule setup with Raspberry Pi

Mon May 20, 2013 6:56 pm

I've been trying hours and I've not been able to mount my hfs+ partition so i can write on it from my Mac. Even after formatting it:

Code: Select all

sudo mkfs.hfsplus -v time_machine /dev/sda2
I can read and write from the RPI but I can only read from the Mac.
How did you do it? @Skyaddict?

remipou
Posts: 4
Joined: Mon May 20, 2013 6:43 pm

Re: Time Capsule setup with Raspberry Pi

Mon May 20, 2013 7:51 pm

Took me a while to get the drive mounting correct so they'd be writable from the Mac
how did you do it?? can't get it to work :-p

elrumo
Posts: 1
Joined: Tue May 28, 2013 7:26 pm

Re: Time Capsule setup with Raspberry Pi

Tue May 28, 2013 7:29 pm

When I run this
sudo apt-get install avahi-daemon libavahi-client-dev libdb5.3-dev db-util db5.3-util libgcrypt11 libgcrypt11-dev
wget http://downloads.sourceforge.net/projec ... .2.tar.bz2
tar -xvf netatalk-3.0.2.tar.bz2
cd netatalk-3.0.2/
./configure --with-init-style=debian --with-zeroconf
make
sudo make install
it says this
Do you want to continue [Y/n]?
then I type the letter Y in and press enter and says abort, does anyone know how to solve this?

ags167
Posts: 4
Joined: Sat Mar 23, 2013 9:19 pm

Re: Time Capsule setup with Raspberry Pi

Fri May 31, 2013 8:06 pm

its says that i should connect as another user or contact the network admin

what should i do

please help

scoopdevon
Posts: 1
Joined: Sat Jun 01, 2013 8:49 am

Re: Time Capsule setup with Raspberry Pi

Sat Jun 01, 2013 8:56 am

Works great except like a few others I found that the drive was read only. I solved it by changing it's permission by....

Code: Select all

sudo chown pi:pi /media/TimeCapsule
Hope it helps someone else :D

remipou
Posts: 4
Joined: Mon May 20, 2013 6:43 pm

Re: Time Capsule setup with Raspberry Pi

Sat Jun 01, 2013 5:28 pm

thanks a lot!!!!
(feel a bit stupid to not have think of it before..)

daverava
Posts: 4
Joined: Wed Jun 05, 2013 9:10 pm

Re: Time Capsule setup with Raspberry Pi

Wed Jun 05, 2013 9:16 pm

I too am getting an error upon install, when i type "y", it just says abort :-/ running through the rest of the steps, when trying to start the time capsule, i receive the message "netatalk: unrecognized service
[ ok ] Stopping Avahi mDNS/DNS-SD Daemon: avahi-daemon.
umount: /media/TimeCapsule: not mounted
fsck.hfsplus: missing special-device
usage: fsck.hfsplus [-c [size] dfl m [mode] npqruy] special-device
c size = cache size (ex. 512m, 1g)
d = output debugging info
f = force fsck even if clean (preen only)
l = live fsck (lock down and test-only)
m arg = octal mode used when creating lost+found directory
n = assume a no response
p, a = just fix normal inconsistencies
q = quick check returns clean, dirty, or failure
r = rebuild catalog btree
u = usage
y = assume a yes response
Usage: mount -V : print version
mount -h : print this help
mount : list mounted filesystems
mount -l : idem, including volume labels
So far the informational part. Next the mounting.
The command is `mount [-t fstype] something somewhere'.
Details found in /etc/fstab may be omitted.
mount -a [-t|-O] ... : mount all stuff from /etc/fstab
mount device : mount device at the known place
mount directory : mount known device here
mount -t type dev dir : ordinary mount command
Note that one does not really mount a device, one mounts
a filesystem (of the given type) found on the device.
One can also mount an already visible directory tree elsewhere:
mount --bind olddir newdir
or move a subtree:
mount --move olddir newdir
One can change the type of mount containing the directory dir:
mount --make-shared dir
mount --make-slave dir
mount --make-private dir
mount --make-unbindable dir
One can change the type of all the mounts in a mount subtree
containing the directory dir:
mount --make-rshared dir
mount --make-rslave dir
mount --make-rprivate dir
mount --make-runbindable dir
A device can be given by name, say /dev/hda1 or /dev/cdrom,
or by label, using -L label or by uuid, using -U uuid .
Other options: [-nfFrsvw] [-o options] [-p passwdfd].
For many more details, say man 8 mount .
netatalk: unrecognized service"

any help would be amazing!

daverava
Posts: 4
Joined: Wed Jun 05, 2013 9:10 pm

Re: Time Capsule setup with Raspberry Pi

Wed Jun 05, 2013 10:35 pm

Ok i've sorted that, typed "yes" instead of "y", but the service still won't start, says netatalk: unrecognized service. Anybody know how to solve this?

Thanks in advance

daverava
Posts: 4
Joined: Wed Jun 05, 2013 9:10 pm

Re: Time Capsule setup with Raspberry Pi

Sat Jun 08, 2013 11:47 am

I'm getting this every time, what am i doing wrong?


[email protected]:~# sudo /etc/init.d/TimeCapsule start
netatalk: unrecognized service
[ ok ] Stopping Avahi mDNS/DNS-SD Daemon: avahi-daemon.
** /dev/sda2
** Checking HFS Plus volume.
** Checking Extents Overflow file.
** Checking Catalog file.
** Checking Catalog hierarchy.
** Checking volume bitmap.
** Checking volume information.
** The volume timecapsule appears to be OK.
netatalk: unrecognized service
[ ok ] Starting Avahi mDNS/DNS-SD Daemon: avahi-daemon.

daverava
Posts: 4
Joined: Wed Jun 05, 2013 9:10 pm

Re: Time Capsule setup with Raspberry Pi

Sat Jun 08, 2013 1:06 pm

Scrap all the previous (and apologies for seeming like a little bitch). I am now at the stage of setting it up with time machine, and it's asking me for a username and password to connect to raspberry.local. What is it that i need to do?

danb35
Posts: 27
Joined: Thu Feb 07, 2013 6:00 pm

Re: Time Capsule setup with Raspberry Pi

Tue Jun 11, 2013 3:32 pm

If it's asking for a username and password, try giving it a username and password--a combination that's valid on the Pi would be good. Unless you've changed from the defaults, that would be pi and raspberry, respectively. And make sure, as scoopdevon posted on 1 Jun, that the pi user has write access to the drive.

danb35
Posts: 27
Joined: Thu Feb 07, 2013 6:00 pm

Re: Time Capsule setup with Raspberry Pi

Tue Jun 11, 2013 3:37 pm

Looking at this and several other guides, I don't understand why they're using HFS+. You're attaching the drive to a Linux system (the Pi), so why not use a Linux native filesystem like ext4? I know from personal experience that Time Machine does not require that the remote storage disk be formatted HFS+ (I have Time Machine backing up in another location to a ZFS volume on a FreeNAS server). That saves a number of packages that need to be installed for this method. The tradeoff is that the drive needs to be formatted and partitioned on the Pi rather than on the Mac.

Also wondering if netatalk 3.0.x is really necessary--2.2.1 seems to support all the necessary features for Time Machine, and can be installed with a simple apt-get install.

danb35
Posts: 27
Joined: Thu Feb 07, 2013 6:00 pm

Re: Time Capsule setup with Raspberry Pi

Fri Jun 14, 2013 4:51 pm

Not to further clutter this thread, but I've come up with another way of doing it:
http://www.raspberrypi.org/phpBB3/viewt ... 36&t=47029

It seems like a simpler solution to me (a single apt-get install, and add one line to each of two config files), but it requires partitioning and formatting the storage drive on the Pi rather than on your Mac. It's working fine for me so far. That's the great thing about Linux--there's almost always more than one way to do something!

kwak
Posts: 1
Joined: Fri Dec 06, 2013 1:47 pm

Re: Time Capsule setup with Raspberry Pi

Fri Dec 06, 2013 1:54 pm

Hi Thanks for instructions; everything seems to work, but I got a problem.
The created "timecapsule' disk is only 6GB. It seems it using my SD card as location.

Where did I go wrong?> How can I fix it?

nick.greening
Posts: 2
Joined: Thu Dec 15, 2016 10:16 am

Re: Time Capsule setup with Raspberry Pi

Fri Dec 16, 2016 10:51 am

Guys,
Please could i have your help, newbie here!???!!

I have successfully set everything up, two Macs performed full back-ups, and then it just stopped backing up. The Macs connect to the drive, in Finder, can see the contents. Only thing that i might have done on the Raspberry is an "sudo apt-get update" & "sudo apt-get upgrade"

When the Time Machine tries to back up, it opens a Finder window called Time Machine Backups there a single folder called Backups.backupdb

I'm using tightvnc to view and control the Raspberry, the Netatalk version is 3.1.10

Any ideas pls?

thanks

Nick


Return to “General discussion”