Garrett L. Ward

Using a Linux Server With Time Machine

Setting up Time Machine to back up over the network to a linux server is now fairly straightforward, since release 2.0.5 of netatalk, the FOSS implementation of Apple’s AFP network file protocol supports time machine volumes out of the box. For this to work, you’ll need a linux computer that’s connected to the same network as your Mac, the latest (2.0.5 at the time of this writing) version of netatalk, which is probably available in your distrobution’s repositories, and the latest avahi.

First, obviously, install netatalk and avahi. You’ll need to set both up so that you announce the share over avahi for your Mac to easily pick it up. Configuring afp is fairly straightforward. Open /etc/netatalk/AppleVolumes.default, and scroll to the bottom. Comment out the ~ line and add the following:

1
2
#~
/path/to/folder share_name options:tm

where /path/to/folder is the path to the folder you want to store the TM backup in and share_name is how the Mac will identify the mount. It can be at most 27 characters and must be enclosed in double quotes if you want spaces in the name, apparently. The options:tm bit tells afpd that you’re going to be using the mount for time machine backups.

Now you need to set up avahi as well. In most modern distros this is straightforward, just install it and start the avahi-daemon daemon. You’ll need add a service description for the AFP share; This is an XML file containing information about the AFP share that avahi will publish to any computers on the network. The service files are usually located in /etc/avahi/services. Here’s the one I use. Change name and host-name as necessary; if you’re not using zeroconf on your network use the ip address of your linux box instead.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<?xml version="1.0" standalone='no'?><!--*-nxml-*-->
<!DOCTYPE service-group SYSTEM "avahi-service.dtd">

<!-- $Id: time_machine.html,v 1.5 2009/10/06 03:47:50 shuey Exp $ -->

<!--
  This file is part of avahi.
 
  avahi is free software; you can redistribute it and/or modify it
  under the terms of the GNU Lesser General Public License as
  published by the Free Software Foundation; either version 2 of the
  License, or (at your option) any later version.

  avahi is distributed in the hope that it will be useful, but
  WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  General Public License for more details.

  You should have received a copy of the GNU Lesser General Public
  License along with avahi; if not, write to the Free Software
  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
  02111-1307 USA.
-->

<!-- See avahi.service(5) for more information about this configuration file -->

<service-group>

  <name replace-wildcards="yes">AFP on helios</name>

  <service>
    <type>_afpovertcp._tcp</type>
    <port>548</port>
    <host-name>helios.local</host-name>
  </service>
  <service>
    <type>_device-info._tcp</type>
    <port>0</port>
    <txt-record>model=Xserve</txt-record>
  </service>

</service-group>

The model=Xserve gives the share an Xserve raid icon in Finder; presumably you could also use model=MacPro or the like if you want something different.

Now then, restart avahi-daemon and afpd, and see if you can at least access the share in finder. You’ll need to log in with your unix username and password, so before we proceed make sure the folder you’re using for backups is writable by the user you’ll log in as. If you don’t see it in finder, try going to connect to server and use afp://ip.of.server to see if it will connect that way; sometimes OSX is a little slow to see new servers on the network.

Once you’ve gotten the AFP server set up you’re almost there. To actually allow Time Machine to use the network share you need to do one final thing. By default Time Machine will ignore network volumes that aren’t time capsules, so open a terminal window on your man and run the following command:

1
defaults write com.apple.systempreferences TMShowUnsupportedNetworkVolumes 1

Now make sure the AFP volume is mounted, and go to set up Time Machine as normal. You should be able to select the network share and start backing up. Now go grab some food or a nap, this will take awhile. Even over a gigabit ethernet connection it took about 4 hours for a 180GB backup.

Musing on OS Choices

So I’m getting a new monitor for Xmas (Yeah, I already know what I’m getting – my mom really needs to learn to use newegg and amazon on her own >_>) and I’ve been debating how to set it up with my current monitor, tv, and macbook pro screen. The debate’s really boiling down to which OS(es) I want to use to accompish something resembling productivity with a multi-monitor setup. For reference, my current setup has my gaming desktop (icarus) and my Macbook Pro (athena) hooked into my current 22” LCD, my old laptop (daedalus) hooked to the tv, and athena’s built-in monitor is kind of there off to the side.

I’ve been using OSX as my main day-to-day OS since I got my Mac in August, and for the most part I really like it. I’ve always loved Expose even in Compiz’s ripped off slightly worse form, and the overall UI feel of OSX is nice. It’s always very responsive, even when doing crazy shit in Virtualbox; certainly the 7200 RPM HDD and 4 GB of ram I upgraded to help in that respect. It’s nice to use an OS that mostly “just works”, though it’s not without it’s faults: bluetooth breaks occasionally, and it rarely doesn’t like to wake up from sleep after about a week of uptime. I also don’t like iTunes for music playback and I haven’t found a good alternative yet; I’ve used MPD in X for the best results, but it depends upon libao which is still somewhat iffy under OSX and suffers from occsional choppiness. I also haven’t found a media player I like quite as much as SMPlayer, but Mplayer OSX does the job well enough. And, of course, there’s a big plus to continuing to use OSX: Time Machine. I’ve never been much on backing up, hence why I don’t have any of my stuff from my first semester at VCU anymore. But I haven’t been burned too badly yet, and between dropbox for my docs and time machine for my all-too-important music collection I think I’m ok there now.

Linux is an appealable alternative as well. I ran it as my day-to-day OS for about 2 years before I migrated to OSX, and I still like going back to it every now and then. I enjoy screwing around with new window managers and the like, and for giant screens (1920x1080 and 1680x1050) a tiling window manager becomes very appreciable. I still run linux on every computer I have but my Mac, and I’ll inevitably have it installed on there as well at some point over break. But will it work reliably for day to day use? Probably if I wasn’t the one using it. But I (apparently) torture my OSes, and that’s most evident when I use Linux and start screwing around with tiling window managers, distcc, or just reconfiguring something important. I’ve tried, I can’t break OSX that much. Linux I can, and while that’s fun it’s also annoying when I need to actually do something for, say, school.

There’s also the issue of software under Linux. Firefox is kind of iffy these days, with slow rendering in Linux even with a PGO build, and don’t get me started on Flash. I’ve messed with Chromium in linux some, and will do so some more before I make a final decision, but I feel like I’d just end up frustrated trying to use FF 3.5 for daily use and I don’t want to have to roll back to 3.0 or 2 :p. The advantage comes in A) cli apps and B) ironically, media apps. I live in the terminal most of the time anyway, even in OSX (X11 + Macports ftw), and obviously that’s even easier to do in Linux. I also have fun, working apps like MPD or cmus for music, and my fav SMPlayer for videos. Overall, though, web browsing is a vital part of my daily routine, and it tends to outweigh the others.

There’s also the Windows option. It’s not a good option, but I may screw around with it just to see. Apparently Win7 is not as bad, and I do kind of miss foobar2000. Plus that way I would’t have to switch inputs and plug my KB and whatnot in just to not play L4D2. Honestly, though, I see less and less use for Windows as I start game less and spend what time I do game on consoles.

The other issue to consider is hardware. The MBP can’t do dual monitors natively. I’d have to either get a USB video card or use an interesting app called ScreenRecycler. It’s shareware, 30 bucks, but “extends” your OSX desktop into a VNC session you can connect to on another computer. Since I have at least one other comp (my server) running at all times this could be a viable option. The other option is synergy(+), which is a software KVM solution. synergy+ is still iffy with Snow Leopard, though; aside from that I’ve used it on *nix/windows hosts before with great success. There’s also the libao issue, but I’ve a crazy idea about that I’ll have to think about as well.

I honestly am not sure where I’ll end up yet, but I just wanted to list the pros and cons as I see them at the moment. Mostly to collect my thoughts so I don’t overlook something obvious as I usually do. I feel like I’ll ultimately end up with OSX + screenrecycler, using my server to drive the secondary display, but we’ll see.

(PS: vipJ in vim will unhardwrap a given paragraph into one long line. Useful for writing posts in vim and then importing to wordpress without nasty hard breaks)