How to Set up an Ubuntu Time Machine Server Using Netatalk

Posted on in: All Posts, How To's.
Tags:

I recently spent some time looking into how to seamlessly backup my Macbook Pro running OSX Mountain Lion onto a spare HDD on my Ubuntu 12.04 Server machine using Time Machine. After a lot of research, trial & error, and finding up to date information, I was able to set up an Ubuntu Time Machine Server by following these general steps:

  1. Setup Your HDD:

    1. Format your HDD (in this case sda1) as ext4, mount it, and make it yours. DO NOT try to format as hfs+ (hfsplus)! Once Time Machine on your Mac attempts to write to your drive, Ubuntu detects journaling and will mount the drive as read-only to protect it. This means that it might work once, but will not work again. Keep it ext2/3/4 or FAT32. NTFS and FAT are also not good options since FAT has filesize restrictions and NTFS may also mount as read-only.

      sudo mkfs.ext4 /dev/sda1
      sudo mkdir /mnt/timeMachine
      sudo mount /dev/sda1 /mnt/timeMachine
      sudo chmod 755 /mnt/timeMachine
      sudo chown YOURUSERNAME:YOURUSERNAME /mnt/timeMachine
    2. Now we need the UUID of your drive (sda1) so we can set it up to auto mount on boot. Run the following, and copy and paste the UUID of your drive somewhere, as you will need it later.

      sudo blkid
    3. Edit fstab:

      sudo nano /etc/fstab
    4. At the bottom of fstab, add the following line. Substitute the UUID that you saved earlier with the one below. Then save the file.

      UUID=b099bb66-b5b1-40ab-8045-e690eabcbc27 /mnt/timeMachine    ext4    defaults        0       2
    5. Reboot and check for errors. If you get errors on boot, your fstab file probably needs work. Here is a link to the fstab documentation if you need help.

      sudo reboot
  2. Setup netatalk & avahi:

    1. Install netatalk & avahi-daemon:

      sudo add-apt-repository ppa:stefanor/ppa
      sudo apt-get update
      sudo apt-get install netatalk avahi-daemon
    2. 2. Edit afpd.conf by running:

      sudo nano /etc/netatalk/afpd.conf
    3. This step is key. Add the following line to the bottom of afpd.conf and save the file. Understand that not every system is the same, so you may have to look into what options fit your needs. These happened to work for me:

      - -tcp -noddp -uamlist uams_dhx.so,uams_dhx2_passwd.so

      If that doesn’t work… research.

    4. Edit AppleVolumes.default by running:

      sudo nano /etc/netatalk/AppleVolumes.default
    5. Add the following line at the bottom of AppleVolumes.default, substitute your username with YOURUSERNAME, and save the file:

      /mnt/timeMachine  "TimeMachine"      options:usedots,upriv,tm ea:ad allow:YOURUSERNAME
    6. Add an entry to avahi so that the server shows up in Finder. Create the file afpd.service by running:

      sudo nano /etc/avahi/services/afpd.service
    7. Then paste the following into afpd.service and save:

      
      
      
      %h
      
      _afpovertcp._tcp
      548
      
      
      _device-info._tcp
      0
      model=Xserve
      
      
    8. Restart netatalk & avahi.

      sudo service netatalk restart & sudo service avahi-daemon restart
  3. Setup your Mac:

    1. Check to see if avahi is working by opening a finder window. If you see your Ubuntu server in the list on the left under SHARED, then avahi is working.

    2. You don’t need to enable unsupported volumes. I’m not sure it matters, but you can disable unsupported volumes by running the following command in a terminal.

      defaults write com.apple.systempreferences TMShowUnsupportedNetworkVolumes 0
    3. Open “System Preferences/Time Machine”, and click the “Select Disk” button. Choose your Ubuntu disk, and click the “Use Disk” button. It should ask you for your “Name” and “Password”. In the “Name” field, enter YOURUSERNAME, and enter the password for that user in the “Password” field. Then click the “Connect” button.

    4. SUCESS… I hope… This is where I ran into issues. If OSX fails to connect, but it’s visible from the “Select Disk” screen, you likely have an issue with your afpd.conf file, your drive isn’t mounting properly, or you have a lack of permissions on /mnt/timeMachine.

Logo smleimberg.com