HOWTO Use Ubuntu As A Mac OS X Time Capsule

Discussion in 'Servers' started by SimplyRyan, Jan 17, 2013.

  1. SimplyRyan

    SimplyRyan

    Joined:
    Jul 28, 2012
    Messages:
    35
    Mobo:
    MSI Z97-SLI
    CPU:
    Core i5 4690K
    Graphics:
    nVidia GT670
    Mac:
    iMac
    Mobile Phone:
    Android, iOS
    Jan 17, 2013 at 8:44 PM #1
    SimplyRyan

    SimplyRyan

    Joined:
    Jul 28, 2012
    Messages:
    35
    Mobo:
    MSI Z97-SLI
    CPU:
    Core i5 4690K
    Graphics:
    nVidia GT670
    Mac:
    iMac
    Mobile Phone:
    Android, iOS
    Preface:


    In past versions of Mac OS X, the built in backup tool, Time Machine 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.


    Code (Text):
     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:


    Code (Text):
    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.


    Code (Text):
    sudo nano /etc/nsswitch.conf
    locate the line that reads


    Code (Text):
    hosts:          files mdns4_minimal [NOTFOUND=return] dns mdns4

    and add 'mdns' to it so it now reads


    Code (Text):
    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


    Code (Text):
    sudo nano /etc/avahi/services/afpd.service

    paste the following code


    Code (Text):

    <?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.


    Code (Text):
    sudo nano /etc/netatalk/AppleVolumes.default

    scroll down to the bottom and find the section that reads
    Code (Text):

    # 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:


    Code (Text):

    # The line below sets some DEFAULT, starting with Netatalk 2.1.
    :DEFAULT: 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


    Code (Text):
    sudo nano /etc/default/netatalk



    find the section that looks like this


    Code (Text):

    #### 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:
    Code (Text):

    #### 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.


    [​IMG]




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

    Originally posted here http://ubuntuforums.org/showthread.php?t=2105755

    EDIT:

    I recently discovered (not sure when it changed) that you need to edit one more file in order to have your AFP shares detected properly and be able to connect to them from the latest version of Mountain Lion (10.8.4 at the time of this writing).

    Code (Text):

    sudo nano /etc/netatalk/afpd.conf
     



    add the following line at the end of the file:


    Code (Text):
    - -tcp -noddp -uamlist uam_guest.so,uams_dhx2_passwd.so -nosavepassword

     
     
  2. SimplyRyan

    SimplyRyan

    Joined:
    Jul 28, 2012
    Messages:
    35
    Mobo:
    MSI Z97-SLI
    CPU:
    Core i5 4690K
    Graphics:
    nVidia GT670
    Mac:
    iMac
    Mobile Phone:
    Android, iOS
    Jan 17, 2013 at 8:45 PM #2
    SimplyRyan

    SimplyRyan

    Joined:
    Jul 28, 2012
    Messages:
    35
    Mobo:
    MSI Z97-SLI
    CPU:
    Core i5 4690K
    Graphics:
    nVidia GT670
    Mac:
    iMac
    Mobile Phone:
    Android, iOS
    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.


    [​IMG]


    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
     
  3. Solidww

    Solidww

    Joined:
    Feb 21, 2011
    Messages:
    1,099
    Mac:
    MacBook Pro
    Mobile Phone:
    iOS
    Feb 21, 2013 at 5:50 PM #3
    Solidww

    Solidww

    Joined:
    Feb 21, 2011
    Messages:
    1,099
    Mac:
    MacBook Pro
    Mobile Phone:
    iOS
    Very cool! Especially, when the file sizes get larger and larger.
     
  4. rabbit74

    rabbit74

    Joined:
    Jan 13, 2010
    Messages:
    699
    Mobo:
    GA-X58A-UD5 - 18G 1600Mhz DDR3 OSX-10.10
    CPU:
    980x
    Graphics:
    Radeon r9 290x + ATi 6850
    Mac:
    MacBook, Mac Pro
    Mobile Phone:
    Android
    Feb 21, 2013 at 7:36 PM #4
    rabbit74

    rabbit74

    Joined:
    Jan 13, 2010
    Messages:
    699
    Mobo:
    GA-X58A-UD5 - 18G 1600Mhz DDR3 OSX-10.10
    CPU:
    980x
    Graphics:
    Radeon r9 290x + ATi 6850
    Mac:
    MacBook, Mac Pro
    Mobile Phone:
    Android
    :clap:
     
  5. hocho

    hocho

    Joined:
    Oct 25, 2010
    Messages:
    3
    Mobo:
    System?
    CPU:
    i7
    Graphics:
    GTX-580
    Feb 21, 2013 at 9:04 PM #5
    hocho

    hocho

    Joined:
    Oct 25, 2010
    Messages:
    3
    Mobo:
    System?
    CPU:
    i7
    Graphics:
    GTX-580
    If you get "There was a problem connecting to the server" it seems to be because of bug in netatalk: https://bugs.launchpad.net/ubuntu/+source/netatalk/+bug/810732

    A workaround mentioned in the bug report worked for me. I added this line to the /etc/default/netatalk:

    AFPD_UAMLIST="-U uams_dhx.so,uams_dhx2_passwd.so"

    This worked atleast with Ubuntu 12.04.2 LTS
     
  6. SJ_UnderWater

    SJ_UnderWater Moderator

    Joined:
    Dec 3, 2010
    Messages:
    706
    Mobo:
    Gigabyte GA-H55M-S2V
    CPU:
    Intel i3-530
    Graphics:
    HIS HD 6570
    Mac:
    iMac
    Mobile Phone:
    Android
    Feb 21, 2013 at 9:51 PM #6
    SJ_UnderWater

    SJ_UnderWater Moderator

    Joined:
    Dec 3, 2010
    Messages:
    706
    Mobo:
    Gigabyte GA-H55M-S2V
    CPU:
    Intel i3-530
    Graphics:
    HIS HD 6570
    Mac:
    iMac
    Mobile Phone:
    Android
    A couple things:
    I know the Ubuntu pkg is seriously-outdated with respect to netatalk releases, but I think it still supports Avahi's DBUS link to register services, meaning the afpd.service is unnecessary. Certainly you didn't add a service for "adisk", the TimeMachine service, so it must already be working. To add a device-info service corresponding to a Mac model (this still doesn't happen correctly by the way, device-info should not be broadcast though Avahi does it), just add a mimicmodel entry to afpd.conf. Something like -mimicmodel TimeCapsule6,106 is a decent choice.
    Default Avahi installations often broadcast other service announcements like SSH, you might want to remove these.
    The volsizelimit entry is a good one to use if you want to limit TimeMachine to a certain amount of space on-disk.
    If you have access to it, I strongly recommend the newer 3.x series instead, which discards all the old AppleTalk machinery, and uses a single service-controller, much easier!

    See Netatalk - ArchWiki
     
  7. SJ_UnderWater

    SJ_UnderWater Moderator

    Joined:
    Dec 3, 2010
    Messages:
    706
    Mobo:
    Gigabyte GA-H55M-S2V
    CPU:
    Intel i3-530
    Graphics:
    HIS HD 6570
    Mac:
    iMac
    Mobile Phone:
    Android
    Feb 23, 2013 at 1:57 AM #7
    SJ_UnderWater

    SJ_UnderWater Moderator

    Joined:
    Dec 3, 2010
    Messages:
    706
    Mobo:
    Gigabyte GA-H55M-S2V
    CPU:
    Intel i3-530
    Graphics:
    HIS HD 6570
    Mac:
    iMac
    Mobile Phone:
    Android
    As someone who has been using netatalk since the Lion/DHX2/SMB issue, I can definitely say 2.2.x supports mimicmodel. In fact, the "-mimicmodel <model>" style only works with 2.2.x, the 3.x style is "mimic model = <model>", like an INI file. See afpd.conf. For the mDNSResponder/Avahi requirement for Bonjour/Zeroconf/mDNS, I refer you to Prerequisites, specifically Optional Third Party Software > Avahi or mDNSResponder. While Time Machine itself will work with any already-mounted AFP share, _afpovertcp and _adisk make the share appear in the disks list without any configuration.
     
  8. Yoyellow

    Yoyellow

    Joined:
    Jan 14, 2010
    Messages:
    114
    Mobo:
    GA-Z87MX-D3H
    CPU:
    i5 4670k
    Graphics:
    nvidia gtx 770
    Mac:
    MacBook Pro, Mac Pro
    Mobile Phone:
    iOS
    Mar 4, 2013 at 2:40 PM #8
    Yoyellow

    Yoyellow

    Joined:
    Jan 14, 2010
    Messages:
    114
    Mobo:
    GA-Z87MX-D3H
    CPU:
    i5 4670k
    Graphics:
    nvidia gtx 770
    Mac:
    MacBook Pro, Mac Pro
    Mobile Phone:
    iOS
    i did exactly this, i can select the disk for time machine, and its starting,but i get stuck at cleaning up, tried again (full reinstall) samme issue, any idea on where this is going wrong?
     
  9. Phreakazoid

    Phreakazoid

    Joined:
    Dec 30, 2011
    Messages:
    1
    Mobo:
    Mountain Lion 10.8.2
    CPU:
    I5 2500k
    Graphics:
    Gigabyte Geforce 560ti
    Mac:
    MacBook Pro
    Mobile Phone:
    iOS
    Mar 6, 2013 at 6:22 PM #9
    Phreakazoid

    Phreakazoid

    Joined:
    Dec 30, 2011
    Messages:
    1
    Mobo:
    Mountain Lion 10.8.2
    CPU:
    I5 2500k
    Graphics:
    Gigabyte Geforce 560ti
    Mac:
    MacBook Pro
    Mobile Phone:
    iOS
    Have u checked permissions for the created directory? It has to be writable for the user or group who is connecting.
    That was my first mistake.
     
  10. beardedgeek

    beardedgeek

    Joined:
    Nov 1, 2013
    Messages:
    2
    Nov 1, 2013 at 9:34 PM #10
    beardedgeek

    beardedgeek

    Joined:
    Nov 1, 2013
    Messages:
    2
    firstly thanks for this :clap: !!

    I got it all working, and was working fine for around a week. now every time I try to connect to the time capsule i get this
    Photo 01-11-2013 09 24 45 pm.jpg

    i haven't changed anything :banghead:

    can any one direct me to what i should to check to see where its failing ?
     

Share This Page