Overview

I decided to "downgrade" some of my media servers from a full-fledged Windows box to a D-Link DNS-323 NAS device. It’s a nice little box, holds 2 SATA drives, and has a network port.

It runs some barebones version of Linux, which I think is BusyBox. It has a built-in iTunes server, a uPnP media server (which doesn’t work with PS3’s, apparently), an FTP server, and a simple web server.

All in all it’s very flexible right from the get-go, but i really wanted it to serve media, so I needed to install MediaTomb (not TwonkyServer, 'cause you have to pay for that, and I hear it’s poorly supported).

Prepping the DNS-323

In order to install MediaTomb, I used Fun Plug. Installing Fun Plug was easy, all it takes is downloading the latest tarball and executable (fun_plug and fun_plug.tgz), dumping them onto the mounted volume (typically /mnt/HD_a2/), rebooting, and grabbing the latest packages and installing them.

After restarting, you’ll want to run the following commands, which will grab all the latest Fun Plug packages over rsync. If you see a funny message about ssh keys and the like, you probably screwed up the syntax of the rsync call. I did the first time 'round. Note that Fun Plug usually sticks itself in /mnt/HD_a2/ffp.

Installing FunPlug
cd /mnt/HD_a2/ffp
rsync -av inreto.de::dns323/fun-plug/0.5/packages ./
cd packages
funpkg -i *.tgz

SSH

Needless to say, SSH is better than telnet, it allows for security, rsync, and all kinds of other fun things. How do we set it all up? Well, I grabbed most of what I needed from here: http://wiki.dns323.info/howto:ffp

In a nutshell, just run these commands:

Enabling SSH
#Set up the root account as a user
pwconv
passwd
usermod -s /ffp/bin/sh root
#Clean up the groups and users
pwck
grpck
#Check to see if it all works!
login
#If it works, commit the passwords to flash
store-passwd.sh
#Get SSH ready, and kill telnet
cd /mnt/HD_a2/ffp/start
chmod a-x telnetd.sh
chmod a+x sshd.sh
reboot

SAMBA

There’s an issue with DNS-323 Samba and OSX.

Here are some fixes I’ve tried that have seemed to work:

From here, add the following line to to /etc/samba/smb.conf, then add the bash script to the end of /mnt/HD_a2/fun_plug.

Append to smb.conf
large readwrite = no
Append to fun_plug
# if no samba config file, then copy the current document to Volume_1
# otherwise, copy the user samba config file and restart samba

# original code on this post, -x tests for smb.conf to be executable.  -e checks
# for file existance
#if [ -x /mnt/HD_a2/smb.conf ]; then

if [ -e /mnt/HD_a2/smb.conf ]; then
        cp /mnt/HD_a2/smb.conf /etc/samba/smb.conf
        smb restart
else
        cp /etc/samba/smb.conf /mnt/HD_a2/smb.conf
fi

Or, from here, you can try this on your OSX machine as root:

Command List
sysctl -w net.inet.tcp.delayed_ack=0
echo 'net.inet.tcp.delayed_ack=0' >> /private/etc/sysctl.conf

Installing MediaTomb

Grab the mediatomb tarball from here: http://www.mediafire.com/?3ndu9sdn3z1

Extract it, then run the following commands to get it all started.

Command List
#You only need to do the following lines once
ln -s /mnt/HD_a2/mediatomb/bin/mediatomb /ffp/sbin/mediatomb
mkdir /mnt/HD_a2/tmp
#You should put this into a script that you run to start mediatomb (run every
time)
LD_LIBRARY_PATH=/mediatomb/lib; export LD_LIBRARY_PATH
mediatomb -d -e egiga0 -p 49152 -m /mnt/HD_a2/mediatomb

Starting MediaTomb

If you want it to start at startup (hehe), you’ll need to add a symlink to the script you created in the funplug startup directory. I called mine start_mediatomb (rather unimaginative, I know), and stuck it in the /mnt/HD_a2/mediatomb/bin directory.

Note Thanks to David of http://www.insightbb.com/ for pointing out that I never explained how to start MediaTomb on startup in my HOWTO.

Now just do the following:

Command List
cd /mnt/HD_a2/ffp/start
#I added the .sh at the end of the filename to make it match the naming
#convention of all the other scripts.  I do not know if funplug runs everything
#the directory, or just runs *.sh
ln -s /mnt/HD_a2/mediatomb/bin/start_mediatomb start_mediatomb.sh
Note

You also might have to chmod a+x the mediatomb binary to make it executable before all of this will work.

Thanks to Ian of http://www.futurehat.com/ for pointing out this omission in my HOWTO.

Troubleshooting MediaTomb

Caution
Chrooting MediaTomb
*Don’t chroot MediaTomb.* It gets very angry and unstable. I tried it, it was sad. If you have any luck, do let me know how you did it.

Help, MediaTomb starts then says "Killed."!

I’ve found that when this happens, it’s likely that your MediaTomb database is corrupted in a way that it can’t detect at start, or something else weird has happened. To fix it, just do the following:

  1. Delete the DB: /mnt/HD_a2/mediatomb/.mediatomb/mediatomb.db

  2. Restart mediatomb!: killall mediatomb; /mnt/HD_a2/mediatomb/bin/start_mediatomb

Customizing MediaTomb

I changed some of the settings in /mnt/HD_a2/mediatomb/.mediatomb/config.xml to better match my personal preferences, like the way it organizes media and what to call itself, but that’s not terribly difficult and the documentation for MediaTomb is pretty good.

Navigating to http://yournasip:49152/ will give you the MediaTomb configuration page (which lets people access your entire filesystem, so unless you’re okay with that, I wouldn’t open that port to the internet). You can add which folders to watch there, pretty easily.

Note that mediatomb will only scan folders every half hour (1800 seconds) or so by default (and it takes FOREVER and half to do the initial spidering of your library), so don’t expect lighting updates like you get from WMP 11.

Here’s my config.xml just for funs (minus things like my passwords, of course):

<?xml version="1.0" encoding="UTF-8"?>
<config version="1" xmlns="http://mediatomb.cc/config/1"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://mediatomb.cc/config/1
http://mediatomb.cc/config/1.xsd">
  <server>
    <ui enabled="yes">
      <accounts enabled="no" session-timeout="30">
        <account user="*********" password="*********"/>
      </accounts>
    </ui>
    <name>MediaTomb</name>
    <udn>uuid:*********</udn>
    <home>/mnt/HD_a2/mediatomb/.mediatomb</home>
    <webroot>/ffp/share/mediatomb/web</webroot>
    <storage>
      <sqlite3 enabled="yes">
        <database-file>mediatomb.db</database-file>
      </sqlite3>
    </storage>
    <protocolInfo extend="yes"/><!-- For PS3 support change to "yes" -->
    <!--
       Uncomment the lines below to get rid of jerky avi playback on the
       DSM320 or to enable subtitles support on the DSM units
    -->
    <!--
    <custom-http-headers>
      <add header="X-User-Agent: redsonic"/>
    </custom-http-headers>

    <manufacturerURL>redsonic.com</manufacturerURL>
    <modelNumber>105</modelNumber>
    -->
    <!-- Uncomment the line below if you have a Telegent TG100 -->
    <!--
       <upnp-string-limit>101</upnp-string-limit>
    -->
  </server>
  <import hidden-files="no">
    <scripting script-charset="UTF-8">
      <virtual-layout type="disabled"/>
    </scripting>
    <mappings>
      <extension-mimetype ignore-unknown="no">
        <map from="mp3" to="audio/mpeg"/>
        <map from="ogg" to="application/ogg"/>
        <map from="asf" to="video/x-ms-asf"/>
        <map from="asx" to="video/x-ms-asf"/>
        <map from="wma" to="audio/x-ms-wma"/>
        <map from="wax" to="audio/x-ms-wax"/>
        <map from="wmv" to="video/x-ms-wmv"/>
        <map from="wvx" to="video/x-ms-wvx"/>
        <map from="wm" to="video/x-ms-wm"/>
        <map from="wmx" to="video/x-ms-wmx"/>
        <map from="m3u" to="audio/x-mpegurl"/>
        <map from="pls" to="audio/x-scpls"/>
        <map from="flv" to="video/x-flv"/>
        <!-- Uncomment the line below for PS3 divx support -->
        <map from="avi" to="video/divx"/>
        <!-- Uncomment the line below for D-Link DSM / ZyXEL DMA-1000 -->
        <!-- <map from="avi" to="video/avi"/> -->
      </extension-mimetype>
      <mimetype-upnpclass>
        <map from="audio/*" to="object.item.audioItem.musicTrack"/>
        <map from="video/*" to="object.item.videoItem"/>
        <map from="image/*" to="object.item.imageItem"/>
      </mimetype-upnpclass>
      <mimetype-contenttype>
        <treat mimetype="audio/mpeg" as="mp3"/>
        <treat mimetype="application/ogg" as="ogg"/>
        <treat mimetype="audio/x-flac" as="flac"/>
        <treat mimetype="image/jpeg" as="jpg"/>
        <treat mimetype="audio/x-mpegurl" as="playlist"/>
        <treat mimetype="audio/x-scpls" as="playlist"/>
        <treat mimetype="audio/x-wav" as="pcm"/>
        <treat mimetype="audio/L16" as="pcm"/>
        <treat mimetype="video/x-msvideo" as="avi"/>
      </mimetype-contenttype>
    </mappings>
  </import>
</config>