Tuesday, January 20, 2015

TomatoUSB minidlna problem when rebooting the router

There is a problem with TomatoUSB (or other routers running minidlna Media DLNA Server) which causes the files.db overwritten each time the rooter is rebooted.

This looks like a problem with mounting usb disk, which happens after the minidlna daemon is run.

I have managed to get my minidlna running quite "stable".

1. Remove dlna startup from services and make it run after the usb drivers are mounted.
The may appare a problem with USB disk with multiple partitions.

You can run "minidlna -f /etc/minidlna.conf" on disk mount, but what if your minidlna database is located on the disk that is not mounted as the first one?

Here's the script that examines your minidlna.conf script and checks if media_dir and db_dir are available after each patitions is mounted.

minidlna_required_dirs=`awk -F "/" '/^db_dir|^media_dir/ {out="/"$2; for(i=3;i<=NF;i++){out=out"/"$i};print out}' $minidlna_conf`

for dir in $minidlna_required_dirs
    if [ -d $dir ]; then

if [ "$minidlna_ready" = true ]; then
  minidlna -f $minidlna_conf

The script will run minidlna if media_dir(s) and db_dir exist. (are mounted).

Put this script in "USB and NAS -> USB Support -> Run after mounting form field.

In the window "Run after remounting" simply put "service dlna stop" or "killall minidlna".

2. Once you generate your config file, by temporarily enabling minidlna in USB and NAS -> Media Server make sure it is saved on the the disk of your router. It will be lost after reboot - remember you won't run minidlna with other services which means the config file won't be generated.

In order to save your config there are 2 ways:
a) saving the config on your /jffs/ partition. For me this was not possible, as my WNR3500Lv1 router cound not mount this partition (too low space.. didn't check this actually).
b) saving the config file in nvram by running command from ssh command line:

nvram setfile2nvram /etc/minidlna.conf

Remember to resave this file if you change it.

Also remember, that there is no much space in nvram.

No comments: