Raspberry Pi Private Cloud (NAS), Time Machine OSX (Yosemite)
The intention is to create a private cloud at home (Within the range of your router). The cloud hosts the TIme Machine and generic storage area for photos and documents. The generic storage should be read/write compatible to Linux and OSX.
The following are required:
Raspberry Pi (Model B) ( Running Raspbian Wheezy, connected to the network, with keyboard and monitor). The procedure to get your PI running is available here.
I have two laptops one is a MacBook Pro ( running OSX Yosemite ) and the other is a Toshiba (running Fedora 20).
Procedure on the Mac : Connect the external hard disk to the MacBook Pro. I have made two partitions of size 333 GB (partition name : timemachine )and 666 GB (partition name : cloud) on my external Hard Drive. The partitioning is done using the “Disk Utility” application (OSX). The file system type chosen is “Mac OS extended (journaled)” (HFS+) for both the partitions.
Run the below command on the terminal to make the OSX recognize non AFP volumes.
defaults write com.apple.systempreferences TMShowUnsupportedNetworkVolumes 1
Procedure on the Pi :
Now connect the External Hard Drive to the Pi.
Install the hfs+ driver.
sudo apt-get install hfsprogs
Create two directories and mount the drives. In my case sda1 was created for Time Machine and sda2 for the generic storage. To find out device names of the external hard drive run the command “lsblk”.
sudo mkdir /home/timemachine sudo chmod 777 /home/timemachine sudo mkdir /home/cloud sudo chomd 777 /home/cloud sudo mount -t hfsplus -o remount,force,rw /dev/sda1 /home/timemachine sudo mount -t hfsplus -o remount,force,rw /dev/sda2 /home/cloud
Update the fstab so that the mount happens automatically during boot.
sudo echo "/dev/sda1 /home/timemachine hfsplus force,rw 0 0" >> /etc/fstab sudo echo "/dev/sda2 /home/cloud hfsplus force,rw 0 0" >> /etc/fstab
Create a user (For egs: cloud), a group (For egs : mycloud) and choose a password (and remember them!!!).
sudo useradd cloud sudo groupadd mycloud sudo useradd -gmycloud cloud sudo passwd cloud sudo chown cloud /home/timemachine sudo chown cloud /home/mycloud
Install samba and netalink:
sudo apt-get install samba samba-common-bin sudo apt-get install netatalk
Configure samba client:
sudo nano /etc/samba/smb.conf
Add the below text at the end of the file. “valid users” should have the name of the group you created:
[cloud] comment = Cloud path = /home/cloud valid users = @mycloud read only = no
Configure the netatalk.
sudo nano /etc/afp.conf
Add the below text to afp.conf:
[Global] mimic model = TimeCapsule6,106 log level = default:warn log file = /var/log/afpd.log [TimeMachine] path = /home/timemachine/ valid users = cloud time machine = yes
sudo echo "/home/timemachine \"Time Machine\" options:tm" >> /etc/netatalk/AppleVolumes.default
restart samba and netatalk and make it start at boot.
sudo service netatalk restart sudo /etc/init.d/samba restart sudo update-rc.d netatalk defaults
Now our private cloud is ready.
To access the private cloud from MacBook Pro:
To access the “general storage” disk on our private cloud open the Finder and select “connect to server”.
Next type in the IP address of the Raspberry Pi (The ifconfig command on the Pi should display the IP address). Do not forget the prefix “smb://” before the IP address. Type in the user name and the password that was created previously.
For time machine :
To access the “Time Machine” disk on our private cloud open the Finder and select “connect to server”.
Next type in the IP address of the Raspberry Pi (The ifconfig command on the Pi should display the IP address). Do not forget the prefix “afp://” before the IP address. Type in the user name and the password that was created previously.
Open Time Machine and press “select disk”. The Time Machine created on our private cloud should be visible. Now you can backup your Mac to this Time Machine Disk on the cloud. It should start creating a sparse bundle. The first backup takes a long time (more than a day) but the next ones will be faster.
Access the private cloud from Fedora :
Open “Files” window and click on “connect to server”.
Put in the Raspberry Pi IP address followed by “smb://”. Type in the user name and the password that was created previously.