DNS-321 as Time Capsule for Mountain Lion

There are several places on the web to find tutorials on setting up a DNS-323 for Time Machine (for example: http://dns323.kood.org), but I couldn’t find sites that discussed setting it up a DNS-321. Here is what I did to get it working.

Root the DNS321 by installing fun_plug

  1. Download fun_plug and fun+plug.tgz
  2. Share the root of DNS-321 via samba (smb)
  3. Add executable rights to the fun_plug script (chmod +x in terminal) from your workstation
  4. Copy fun_plug and fun_plug.tgz to root of DNS321 and reboot (wait a bit as it takes a while to run)


Setup the root user account for SSH access

  1. Connect to the DNS-321 via Telnet :
    $ telnet your.nas.ip.address
  2. Change the shell of the root account
    ~# usermod -s /ffp/bin/bash root
  3. Create a home folder for the root account
    ~# mkdir -p /ffp/home/root/
  4. Set the home folder of the root account to the be the folder that was created in the previous step
    ~# usermod -d /ffp/home/root/ root

    If the above fails, manually edit the /etc/passwd file so the root account looks like this

    root:x:0:0:Linux User,,,:/ffp/home/root:/ffp/bin/bash

    Then, run the following command

    ~# pwconv
  5. Set the root account to have a password
    ~# passwd
  6. Login as the root account
    ~# login
  7. Save the root password you created by running the following command. This command invokes another shell (.sh) script which copies the password-related files to data partitions in Flash memory (mtd1 and mtd2).
    ~# store-passwd.sh
  8. Activate the SSH service by running the following commands:
    ~# chmod a+x /ffp/start/sshd.sh
    # sh /ffp/start/sshd.sh start


Install Netatalk (AFPD) on the DNS-321

  1. Modify /ffp/etc/netatalk/afpd.conf, adding the following to the bottom of the file
    - -tcp -noddp -uamlist uams_dhx2.so,uams_clrtxt.so -setuplog "default log_info /ffp/var/run/afpd.log" -cnidserver localhost
  2. Install libgcrypt, libgpg-error, netatalk using slacker
    ~# slacker -Ui s:
  3. Install libdb5 by either compiling your own or using the one in the following forum: http://forum.dsmg600.info.
  4. Create two startup scripts: /ffp/start/afpd.sh and /ffp/start/cnid_metad.sh:


    # PROVIDE: afpd
    # REQUIRE: cnid_metad
    . /ffp/etc/ffp.subr
    run_rc_command "$1"


    # PROVIDE: cnid_metad
    . /ffp/etc/ffp.subr
    run_rc_command "$1"
  5. Make the scripts executable by running the following commands:
    ~# chmod +x /ffp/start/afpd.sh
    # chmod +x /ffp/start/cfid_metad.sh
  6. Create /ffp/etc/avahi/services/afpd.service and set its contents be as shown below:
    <?xml version="1.0" standalone="no"?><!--*-nxml-*-->
    <!DOCTYPE service-group SYSTEM "avahi-service.dtd">
        <name replace-wildcards="yes">%h</name>
  7. Use the “vipw” command and change some details for the default “nobody” user so that Mac OS X can use that user to log in.
    nobody:x:501:501:Linux User,,,:/home/nobody:/ffp/bin/bash
  8. Give a password to that user and store the password (in clear text) in the user’s home directory as shown here.
    ~# passwd nobody
    # cd /home
    # mkdir nobody
    # echo "secret" &gt; nobody/.passwd
    # chown -R nobody: nobody
  9. Store this user’s information in the flash memory of the DNS-321. Do this by running the following command
    ~# store-passwd.sh
  10. Modify /ffp/etc/netatalk/AppleVolumes.default to add the required shares. Mine looks like:
    ~# The "~" below indicates that Home directories are visible by default.
    # If you do not wish to have people accessing their Home directories,
    # please put a pound sign in front of the tilde or delete it.
    # ~     
    /mnt/HD_a2/TimeMachine options:usedots,upriv,tm
  11. Start netatalk
    ~# /ffp/start/afpd.sh start


Install Avahi (bonjour) on the DNS-321

  1. Install libdaemon and avahi with slacker:
    ~# slacker -Ui s:
  2. Add an avahi user:
    ~# groupadd -g 50 avahi
    ~# useradd -u 50 -g avahi -d /tmp -s /bin/false avahi
  3. Create an avahi startup script called /ffp/start/avahi.sh that contains the following:
    # PROVIDE: avahi
    . /ffp/etc/ffp.subr
    avahi_daemon_flags="-D -s"
    required_files="/ffp/etc/avahi/avahi-daemon.conf /ffp/etc/avahi/hosts"
    # need avahi user and group for priviledge separation
    if ! grep '^avahi:' /etc/passwd &gt;/dev/null; then
    echo 'avahi:x:50:50:Avahi Daemon:/no/where:/bin/false' &gt;&gt;/etc/passwd
    if ! grep '^avahi:' /etc/shadow &gt;/dev/null; then
    echo 'avahi:*:14493:0:99999:7:::' &gt;&gt;/etc/shadow
    if ! grep '^avahi:' /etc/group &gt;/dev/null; then
    echo 'avahi::50:avahi' &gt;&gt;/etc/group
    proc_start $command
    run_rc_command "$1"
  4. Make the file executable so that avahi starts when the DNS-323 boots:
    ~# chmod +x /ffp/start/avahi.sh
  5. To change the icon for the DNS-321 that shows up in Mac OS X Finder, create the file /ffp/etc/avahi/services/device-info.service and set its contents to the following:
    <?xml version="1.0" standalone="no"?><!--*-nxml-*-->
            <name replace-wildcards="yes">%h</name>
  6. Launch avahi
    ~# /ffp/start/avahi.sh

You should now see your DNS-321 show up in Finder.