How to Install MiniDLNA on FreeNAS 9.3 (Prior to Plugin)

joeschmuck

Old Man
Moderator
Joined
May 28, 2011
Messages
10,994
Can you give me some specifics as to how many files you are trying to service and the version of MiniDLNA? I can't say I'll figure out a solution but if I could replicate it, well maybe I could figure out something.
 

joeschmuck

Old Man
Moderator
Joined
May 28, 2011
Messages
10,994
I'd like to add here that Plex also has a built in DLNA server, you do not need to use the transcoding if you have limited processing power or a Plex player. With as many files as some people have, I'm not sure how it will handle it but maybe it will not run into the same issue.
 

frankvh

Dabbler
Joined
Sep 7, 2015
Messages
10
Hi Joeschmuck,

Yes, I do run Plex, along with miniDLNA. Both running in different jails, Plex of course installed from the plugins. I do prefer miniDLNA because I find it quicker to respond to queries from my client devices. So it's always my first choice, however Plex is there as a backup, so to speak. It's not really a problem to manually stop & start the miniDLNA jail to force miniDLNA to refresh its library. For me, it'd be nice if inotify / knotify worked, but it's not a showstopper.

This is what miniDLNA is seeing:

FreeNAS-9.3-STABLE-201509022158

root@miniDLNA:/ # pkg search minidlna
minidlna-1.1.4_1,1

media folder:
385 GB
73,875 files
1,780 Folders

(lots of photos - seems I need to get better at deleting them - but I don't want to! :) )

Thanks again.

Frank.
frankvh.com
 

kingcharles

Dabbler
Joined
Dec 2, 2012
Messages
17
MiniDLNA has been running rock solid for me too after disabling inotify, apologies for not following up sooner

My system today:
FreeNAS-9.3-STABLE-201508250051
minidlna-1.1.4_1,1
Serving 26179 items, a total of 217,5 GB
 

joeschmuck

Old Man
Moderator
Joined
May 28, 2011
Messages
10,994
OUCH! You both have tons of files. I'd have to write a script to copy some files and rename each on with maybe an incremental number like "music1.mp3" "music2.mp3" even though they are all the same song. This would get me to a very high file count quickly and chew up so drive space. I was hoping kqueue was fixed better in this later version because I know it was fixed to work. There must be a file limitation. I've had a very long day at work today so I won't be working this issue today but I'll see what I can do about it soon. For now I'll just generate a script to create thousands of music files and get that running.

EDIT: So I wrote a simple script to copy a single mp3 music file and rename it into several different subdirectories. I've created over 76,630 files which consumes over 268GB. I have my test bed of files created. The hard drives were banging away like crazy and the system paused a few times. 16GB of RAM limitation I guess. I can create more files easily if needed.
 
Last edited:

joeschmuck

Old Man
Moderator
Joined
May 28, 2011
Messages
10,994
So I've increased the file count a bit last night while I was sleeping. 676,638 files using 2.32TB. Guess I'll trim that down a bit since it only leaves 360GB of free space left.
 

Peter Jakab

Dabbler
Joined
Jun 18, 2015
Messages
37
Hi All,

I used the method above and very happy with that:
- inotify refresh after upload file no restart jail needed:)
- I Panasonic plazma I able use the
Code:
# always force SortCriteria to this value, regardless of the SortCriteria passed by the client
force_sort_criteria=+upnp:class,+upnp:originalTrackNumber,+dc:title

this is sort by Names due overwrite client request sort by date (which is mean for me upload date of the file).

But I have little problem. I used external link to media folder. I used "Add storage to jail" and setup this folder as media root. But I see that when stopping jail

warden stop MiniDLNA2
Stoppingthejail....192.168.10.37 (192.168.10.37) deleted
Unmounting user-supplied file-systems
umount: unmount of /mnt/demovol/jails/MiniDLNA2/media failed: Device busy
Stopping jail with: /etc/rc.shutdown

I need wait lot of time here and after

"Killed
...Done"

Could they try unmount linked storage before MiniDLNA stopped? This is also slow down the general shutdown time for NAS. No other jail slow as this one.

Bye,
Jackson
 

rogerh

Guru
Joined
Apr 18, 2014
Messages
1,111
Hi All,

I used the method above and very happy with that:
- inotify refresh after upload file no restart jail needed:)
- I Panasonic plazma I able use the
Code:
# always force SortCriteria to this value, regardless of the SortCriteria passed by the client
force_sort_criteria=+upnp:class,+upnp:originalTrackNumber,+dc:title

this is sort by Names due overwrite client request sort by date (which is mean for me upload date of the file).

But I have little problem. I used external link to media folder. I used "Add storage to jail" and setup this folder as media root. But I see that when stopping jail

warden stop MiniDLNA2
Stoppingthejail....192.168.10.37 (192.168.10.37) deleted
Unmounting user-supplied file-systems
umount: unmount of /mnt/demovol/jails/MiniDLNA2/media failed: Device busy
Stopping jail with: /etc/rc.shutdown

I need wait lot of time here and after

"Killed
...Done"

Could they try unmount linked storage before MiniDLNA stopped? This is also slow down the general shutdown time for NAS. No other jail slow as this one.

Bye,
Jackson
I have the same problem. Does everyone's minidlna take several minutes to shut down, or could this be a configuration error?
 

joeschmuck

Old Man
Moderator
Joined
May 28, 2011
Messages
10,994
I think it just takes a bit of time for the jail to shutdown. I haven't had any time to do anything with MiniDLNA and will not this week, too much family stuff going on.
 

rogerh

Guru
Joined
Apr 18, 2014
Messages
1,111
I've established that "kill <minidlna PID>" consistently takes two or three minutes to shutdown, while "kill -9 <minidlna PID>" is instantaneous for human purposes. Which leaves two problems, firstly to discover whether this way of shutting down minidlna is going to corrupt its database or damage media files, and secondly, how to make the arcane BSD init process send a different shutdown signal to one program.

Ideally, someone would fix the port.
 

joeschmuck

Old Man
Moderator
Joined
May 28, 2011
Messages
10,994
Ideally, someone would fix the port.
Ideally.

When FreeNAS 10 comes out we should be able to create a true Linux VM and run MiniDLNA without issue.
 

rogerh

Guru
Joined
Apr 18, 2014
Messages
1,111
Ideally.

When FreeNAS 10 comes out we should be able to create a true Linux VM and run MiniDLNA without issue.
That sounds good - though it means I won't have an excuse to play with FreeBSD!

I've got a fix for the slow shutdown of MiniDLNA. It is not guaranteed, a) to work!, or b) to refrain from destroying media files, pools, OS and anything else within reach so don't blame me if you try it.

Add the following to /usr/local/etc/rc.d/minidlna:

Code:
stop_cmd="hardstop"

hardstop()

{

     if     [ -z "$rc_pid" ]; then
            [ -n "$rc_fast" ] && return 0
                _run_rc_notrunning
            return 1
        fi

        _run_rc_precmd || return 1

                                     # send the signal to stop
                                     #
        echo "Stopping ${name}."
        _doit=$(_run_rc_killcmd "${sig_stop:-KILL}")
        _run_rc_doit "$_doit" || return 1

                                      # wait for the command to exit,
                                      # and run postcmd.
        wait_for_pids $rc_pid

        _run_rc_postcmd

}



I put it straight after the other command definitions, ending up with:


Code:
#!/bin/sh
#
# $FreeBSD: head/net/minidlna/files/minidlna.in 323762 2013-07-26 23:25:40Z wg $
#
# PROVIDE: minidlna
# REQUIRE: LOGIN
# KEYWORD: shutdown
#
# Add the following line to /etc/rc.conf[.local] to enable minidlna:
#
# minidlna_enable="YES"

. /etc/rc.subr

name=minidlna
rcvar=minidlna_enable

load_rc_config $name

minidlna_enable=${minidlna_enable-"NO"}
minidlna_uid=${minidlna_uid-"dlna"}

command=/usr/local/sbin/minidlnad
pidfile="/var/run/minidlna/minidlna.pid"
command_args="-P $pidfile -u $minidlna_uid -f /usr/local/etc/minidlna.conf"

start_precmd="install -d -o $minidlna_uid ${pidfile%/*} /var/db/minidlna"
stop_postcmd="rm -f $pidfile"

stop_cmd="hardstop"

hardstop()

{

        if      [ -z "$rc_pid" ]; then
                [ -n "$rc_fast" ] && return 0
                 _run_rc_notrunning
                return 1
        fi

        _run_rc_precmd || return 1

                                     # send the signal to stop
                                     #
        echo "Stopping ${name}."
        _doit=$(_run_rc_killcmd "${sig_stop:-KILL}")
        _run_rc_doit "$_doit" || return 1

                                      # wait for the command to exit,
                                      # and run postcmd.
        wait_for_pids $rc_pid

        _run_rc_postcmd

}

extra_commands=rescan
rescan_cmd="$command -R -u $minidlna_uid -f /usr/local/etc/minidlna.conf"

run_rc_command $1



The effect is that when minidlna is stopped by the init processes it is sent a KILL command instead of a TERM command. This NOT a good thing to do, but it seems to work.



Edit: the unmounting of the media folders from the pool mounted in the jail still appears to fail, and it is possible that this is the underlying problem. But there is no longer a long delay due to minidlna not shutting down and the jail not shutting down.
 
Last edited:

hervon

Patron
Joined
Apr 23, 2012
Messages
353
Thanks rogerh. Trying just for fun. I'll let you know how it goes.
 

joeschmuck

Old Man
Moderator
Joined
May 28, 2011
Messages
10,994
That sounds good - though it means I won't have an excuse to play with FreeBSD!
Oh, I'm sure there will be something to play with.

Also, I have used the KILL command in the early days of MiniDLNA and coming up with a working script, I never experienced an issue with the mounted pools, meaning no corrupt data. BUT, as mentioned above, anyone who does this is taking a risk until proven otherwise.

Thursday I "should" be able to start looking into the MiniDLNA issues at hand, see if I can recreate the issues and then find a proper solution. This is assuming things go well. Right now my riding lawnmower is dead, cracked case, blown camshaft gear. I need to fix it or pay someone to cut my lawn. Fixing it would be what I need to do, paying some kid in the neighborhood is fine too but these kids charge more these days. Eh, at least the kids are trying to earn money vice stealing or daddy just giving it to them.
 

rogerh

Guru
Joined
Apr 18, 2014
Messages
1,111
Good luck with the grass! It's about finished growing now at UK latitudes.
 

kingcharles

Dabbler
Joined
Dec 2, 2012
Messages
17
Right now my riding lawnmower is dead, cracked case, blown camshaft gear. I need to fix it or pay someone to cut my lawn. Fixing it would be what I need to do, paying some kid in the neighborhood is fine too but these kids charge more these days. Eh, at least the kids are trying to earn money vice stealing or daddy just giving it to them.

Or get something more high tech, this way I know we will have a FreeNAS mowing plugin soon...
http://www.husqvarna.com/us/products/robotic-mowers/husqvarna-robotic-mowers-for-homeowners/

Happy mowing ;)
 

Chronic

Cadet
Joined
Oct 28, 2014
Messages
9
I've installed minidlna in a jail but I have to disable inotify or it crashes. It also does not update my database automatically, I have to have a restart of the minidlna service in FreeNAS cron for it to update the database.
 

joeschmuck

Old Man
Moderator
Joined
May 28, 2011
Messages
10,994
I've installed minidlna in a jail but I have to disable inotify or it crashes. It also does not update my database automatically, I have to have a restart of the minidlna service in FreeNAS cron for it to update the database.
That is normal behavior you are describing.

Or get something more high tech, this way I know we will have a FreeNAS mowing plugin soon...
http://www.husqvarna.com/us/products/robotic-mowers/husqvarna-robotic-mowers-for-homeowners/

Happy mowing ;)
I spent about $150 and fixed it myself. A little J-B WELD for the cracked case, a new Camshaft to replace the shattered one, some Valve Grinding compound to clean up the flywheel to crankshaft seating, MASS Airflow Cleaner (any good degreaser will work) to clean the inside of the engine and some of the outside, a gasket set, oil and filter, some elbow grease, and a dremel tool to make a custom flywheel shear pin and it runs like a charm again. The camshaft cost the most money and it broke due to poor design. Eh, it's done now so lets hope I many more years out of this before it breaks again.

Also, I may have some time to look into the MiniDLNA problem with all those files but no promises, My dad is now moving in with us, should be interesting.
 
Top