PDA

View Full Version : [ubuntu] HOWTO Use Ubuntu As A Mac OS X Time Capsule



N00b-un-2
January 17th, 2013, 05:30 AM
Preface:

In past versions of Mac OS X, the built in backup tool, Time Machine (http://en.wikipedia.org/wiki/Time_Machine_(Mac_OS)) was a lot less picky about where you back up your files to. You could even back up to a Samba file share if you enabled the "unsupported volumes" hack.


defaults write com.apple.systempreferences TMShowUnsupportedNetworkVolumes 1


But that ended with Snow Leopard. Starting with the release of OSX 10.7 Lion, Apple started cinching down on where you could back up your system to, ostensibly for security reasons. Now, with Mac OS X 10.8 "Mountain Lion", it's gotten to the point where essentially the only places you can back up your system using Time Machine are either on another Mac OS X File Server or on an Apple Time Capsule. My assumption is that their intent is merely to bolster their hardware sales.

I don't know too many people who stay exclusively within the "walled garden" for all their computing needs. Certainly people with a lot more money to burn than me. But for a much more economical approach than shelling out around $300 for an over-glorified USB drive, you could just follow this guide to set up your Ubuntu file server to look and behave exactly like Time Machine would expect a real Time Capsule or Mac to.

Step 1: Install Netatalk

installing Netatalk, the open source Apple Filing Protocol (AFP) implementation is easy! The packages are already in the repos, which makes me wonder why it's not enabled by default.

Install the following packages:


sudo apt-get install netatalk libc6-dev avahi-daemon libnss-mdns

Step 2: Configure /etc/nsswitch.conf

Once those packages are installed, there are actually 4 configuration files that need to be edited in order for the Macs on your network to access your AFP shares properly.


sudo nano /etc/nsswitch.conf
locate the line that reads


hosts: files mdns4_minimal [NOTFOUND=return] dns mdns4

and add 'mdns' to it so it now reads


hosts: files mdns4_minimal [NOTFOUND=return] dns mdns4 mdns

press ctrl+o to save and ctrl+x to exit.

Step 3: /etc/avahi/services/afpd.service


sudo nano /etc/avahi/services/afpd.service

paste the following code



<?xml version="1.0" standalone='no'?><!--*-nxml-*-->
<!DOCTYPE service-group SYSTEM "avahi-service.dtd">
<service-group>
<name replace-wildcards="yes">%h</name>
<service>
<type>_afpovertcp._tcp</type>
<port>548</port>
</service>
<service>
<type>_device-info._tcp</type>
<port>0</port>
<txt-record>model=TimeCapsule</txt-record>
</service>
</service-group>


NOTE: Just for fun you can change the string "<txt-record>model=TimeCapsule</txt-record>" to the following devices to change how they appear in Finder on OSX:


MacBook
Laptop
MacBook4,1,Black
MacBookPro
MacBookAir
MacPro
iMac
Macmini
AppleTV
iPhone
iPodTouch
iPad
Xserve
RackMac
TimeCapsule
PowerBook
PowerMac
AppleTV1
AppleTV2
AirPort

Type them exactly as I have typed them. They are case sensitive. If you type the model name in wrong, your AFP share will show up as a Cinema Display in Finder. There are actually dozens more. Too many to list actually, but if you're interested you can find the name strings in /System/Library/CoreServices/CoreTypes.bundle/Contents/Info.plist

Step 4: /etc/netatalk/AppleVolumes.default

This is where you actually declare your shared file.


sudo nano /etc/netatalk/AppleVolumes.default

scroll down to the bottom and find the section that reads


# The line below sets some DEFAULT, starting with Netatalk 2.1.
:DEFAULT: options:upriv,usedots

# By default all users have access to their home directories.
~/ "Home Directory"

# End of File


change the path "~/" (which points to /home/username) to the directory you want to share. For me I created a separate partition mounted at /TimeCapsule.

IMPORTANT!!! You would be able to access the share from a Mac, but if you plan to use this share for Time Machine backup, you need to add 'tm' to options:upriv,usedots
like this:



# The line below sets some DEFAULT, starting with Netatalk 2.1.
:DEFAULT: cnidscheme:dbd options:upriv,usedots,tm

# By default all users have access to their home directories.
/TimeCapsule "Time Capsule"

# End of File


press ctrl+o to save and ctrl+x to exit.

Step 5: /etc/default/netatalk

this is the last file that you need to edit. Edit with


sudo nano /etc/default/netatalk


find the section that looks like this



#### Set which legacy daemons to run.
#### If you need AppleTalk, run atalkd.
#### papd, timelord and a2boot are dependent upon atalkd.
ATALKD_RUN=no
PAPD_RUN=no
TIMELORD_RUN=no
A2BOOT_RUN=no


and edit it so it looks like this:


#### Set which legacy daemons to run.
#### If you need AppleTalk, run atalkd.
#### papd, timelord and a2boot are dependent upon atalkd.
ATALKD_RUN=no
PAPD_RUN=no
CNID_METAD_RUN=yes
AFPD_RUN=yes
TIMELORD_RUN=no
A2BOOT_RUN=no


That is all. Now you can enjoy making incremental backups with Time Machine without the hassle of manually mounting disks. I actually did this on my Windows 8 HTPC/Mediaserver using a very stripped down headless Debian virtualbox installation that runs at boot as a background service and uses only 64MB of RAM and paravirtualized bridged ethernet.

http://img846.imageshack.us/img846/1334/screenshot20130116at925.png (http://imageshack.us/photo/my-images/846/screenshot20130116at925.png/)


Screenshot of my Mac backing up to the Debian virtual machine on my Windows 8 box.

N00b-un-2
January 17th, 2013, 09:34 PM
Just in case anyone is interested, here is the complete list of icons and how to make your Ubuntu AFP shares take on that image. On OSX 10.7 and 10.8, there are only 8 monochromatic icons used (Laptop, Macmini, MacPro, iTouch, iPhone, iPad, iMac and Time Capsule) but if you use a hack like "Side Effects" on Lion or Mountain Lion, or if you are still on Snow Leopard or before, any of these icons will work for you. It's probably safe to assume that on Tiger or Leopard which are already past EOL there probably isn't support for a lot of the newer icons.

http://img850.imageshack.us/img850/5656/screenshot20130117at124.png (http://imageshack.us/photo/my-images/850/screenshot20130117at124.png/)

Apple Cinema Display = Any invalid or blank string

Airport Express = AirPort4 AirPort4,102 AirPort4,107

Airport Extreme = AirPort Airpor5 AirPort5,104 AirPort5,105 AirPort5,108 AirPort5,114 AirPort5,117

AppleTV = AppleTV AppleTV1,1

eMac = PowerMac4,4 PowerMac6,4

iBook G4 = PowerBook6,3 PowerBook6,5 PowerBook6,7

Aluminum 20" iMac = iMac7,1 iMac8,1

Aluminum 24" iMac = iMac9,1

"Flower Pot" G4 iMac 15" = PowerMac4,2

"Flower Pot" G4 iMac 17" = PowerMac4,5 PowerMac6,1

"Flower Pot" G4 iMac 20" = PowerMac6,3

Unibody G5 iMac 17" = PowerMac8,1 PowerMac8,2

Unibody G5 iMac 17" w/ iSight = PowerMac12,1

iMac 24" = iMac4,1 iMac4,2

Unibody iMac 21" = iMac11,2 iMac12,1

Unibody iMac 27" = iMac10,1 iMac11,1 iMac11,3 iMac12,2

iPad = iPad iPad1,1

iPhone = M68AP iPhone1,1

iPhone3G = N82AP iPhone1,2

iPhone4 = N90AP iPhone iPhone3,1

iPodTouch = N45AP iPod1,1

iPod Touch 2 = N72AP iPod2,1

iPod Touch 4 = N81AP iPod4,1

Black MacBook = MacBook1,1,Black MacBook2,1,Black MacBook3,1,Black MacBook4,1,Black

White Unibody MacBook = MacBook6,1 MacBook7,1

Aluminum Unibody MacBook = MacBook5,1

White MacBook = MacBook1,1 Macbook2,1 MacBook3,1 MacBook4,1 MacBook5,2 MacBook1,1,White MacBook2,1,White MacBook3,1,White MacBook4,1,White

MacBook Air = MacBookAir1,1 MacBookAir2,1

MacBook Air Unibody 11" = MacBookAir3,1 MacBookAir4,1 MacBookAir5,1

MacBook Air Unibody 13" = MacBookAir3,2 MacBookAir4,2 MacBookAir5,2

MacBook Pro 13" = MacBookPro5,5 MacBookPro7,1 MacBookPro8,1 MacBookPro9,1

Retina MacBook Pro 15" = MacBookPro

Unibody MacBook Pro 15" = MacBookPro5,1 MacBookPro5,3 MacBookPro5,4 MacBookPro6,2 MacBookPro8,2 MacBookPro9,2

Unibody Macbook Pro 17" = MacBookPro5,2 MacBookPro6,1 MacBookPro8,3

Silver MacBook Pro = Laptop

Mac Mini w/o Disk Drive = Macmini Macmini5,1 Macmini5,2 Macmini5,3

Mac Mini w/ Disk Drive = Macmini4,1

Old Mac Mini = PowerMac10,1 PowerMac10,2

MacPro = MacPro MacPro1,1 MacPro2,1 MacPro3,1 MacPro4,1 MacPro5,1

PowerBook G4 12" = PowerBook6,1 PowerBook6,2 PowerBook6,4 PowerBook6,8

PowerBook G4 15" = PowerBook5,2 PowerBook5,4 PowerBook5,6 PowerBook5,8

PowerBook G4 17" = PowerBook5,1 PowerBook5,3 PowerBook5,5 PowerBook5,7 PowerBook5,9

Titanium PowerBook = PowerBook3,2 PowerBook3,3 PowerBook3,4 PowerBook3,5

Graphite G4 PowerMac = PowerMac

Quicksilver G4 PowerMac = PowerMac3,5

Time Capsule = AirPort6 AirPort6,106 TimeCapsule TimeCapsule6 TimeCapsule6,106 TimeCapsule6,109 TimeCapsule6,113 TimeCapsule6,116

XServe = RackMac RackMac1,1 RackMac1,2 RackMac3,1 Xserve Xserve1,1 Xserve2,1 Xserve3,1

PartisanEntity
November 18th, 2014, 10:43 PM
For anyone interested in this How To, I can confirm that it is working on Ubuntu Server 14.04 LTS.

peartaa
November 23rd, 2014, 02:52 AM
I've used this how-to before on a different machine and it worked fine, but I'm now doing it on a new machine, but with the same disk that contained the backup file from the old machine.

after following the instructions, I tried to reboot my computer and it hung on the xubuntu splash screen indefinitely - would not boot

I booted into a live cd and (on a hunch) tried renaming the file
/etc/avahi/services/afpd.service

to afpd.service.old.

I was then able to boot, and saw "Time Capsule" from my mac, but when I tried connecting, I got this error "Unable to connect" (link to screenshot): https://www.dropbox.com/s/9yjpsniuhpy7rwc/Screenshot%202014-11-22%2020.46.04.png?dl=0

and an error showed up on my Xubuntu box as well, "System program problem detected" and it wanted to submit a bug report.

I'll continue working on it and post updates. Of course, I'll welcome any insight or help of any kind :)

melat0nin
December 15th, 2014, 11:15 PM
Thanks for the guide!

I followed the steps exactly but although I can see the server in Finder I can't see it as a disk option in Time Machine (Yosemite, and Ubuntu Server 14.04). Any thoughts why this is? I also have Samba set up through Webmin, if that makes any difference.

melat0nin
December 16th, 2014, 11:37 AM
Thanks for the guide!

I followed the steps exactly but although I can see the server in Finder I can't see it as a disk option in Time Machine (Yosemite, and Ubuntu Server 14.04). Any thoughts why this is? I also have Samba set up through Webmin, if that makes any difference.

I managed to get it working using the guide here: http://d43.me/blog/1660/concisest-guide-to-setting-up-time-machine-server-on-ubuntu-server-12-04/

The main difference is the share definition in /etc/netatalk/AppleVolumes.default, and using a separate user account with its own home folder to contain the Time Capsule files.