Register for the iXsystems Community to get an ad-free experience and exclusive discounts in our eBay Store.

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

joeschmuck

Old Man
Moderator
Joined
May 28, 2011
Messages
8,258
How to install MiniDLNA into a FreeNAS 9.3, 9.10.x., 11.x (original GUI & New GUI) Jails (warden and iocage).

It appears that FreeNAS has no plans to incorporate a simple DLNA server for FreeNAS 9.3 and later so this thread contains detailed instructions to install MiniDLNA in a jail, your other option is to use Plex which does have a very good built in DLNA server.

This thread is for those folks who want to manually install MiniDLNA into a jail and I will give you step by step instructions to achieve that.

One thing to note, this is only to restore MiniDLNA functionality and nothing more since the Plugin was removed from FreeNAS. MiniDLNA does have some limitations which I cannot get past as MiniDLNA was a port from Linux, and FreeBSD and Linux are not the same thing. If MiniDLNA doesn't do it for you then I suggest installing Plex Media Server and using the built in DLNA server.

There are a few assumptions:
1) Your FreeNAS network is already configured and can access the internet.
2) You have some videos/music ready to be shared on your FreeNAS server.

If you have any issue with a step below, reference the step that worked last and the step you are having issue with. This may sound odd but this is the way to ensure you are provided accurate help.

So lets get started...

UPDATE! I have made some changes with the layout, I wasted to maintain the same numbering system to ensure the steps remained basically the same. If you have a problem then you should be able to read through the thread and if someone had an issue before, it would still relate if they found an answer. I also called the sections of steps by "Old GUI" and "New GUI". Pay attention to what you are doing and it should all go well.

Creating the Jail (Old GUI)
1) You 'should' identify an IP address you will use for the MiniDLNA server or you can use DHCP if you must. For my example I will use 192.168.1.54.
2) In the FreeNAS GUI click on the Jails Icon
3) Click on Add Jail
4) Click on the Advanced Mode button
5) Enter the Jail Name MiniDLNA (Note: You could call it FreeBSD as you can use this jail for much more than just MiniDLNA, but for this purpose we will simply call it MiniDLNA)
6) Now comes the tricky part, do you use DHCP or a static IP address.
a) DHCP: Click DHCP and skip to step 7
b) Static IP Address: Fill in IPv4 address, netmask /24 (255.255.255.0), and default gateway. In my case the values are address: 192.168.1.54, netmask: /24 (255.255.255.0), default gateway: 192.168.1.1
7) Scroll to the bottom of the screen and click OK (Leave Autostart and VIMAGE checked)
8) If this is the first time creating a FreeBSD jail then you will have a large download start up.
9) At the completion you should have a standard jail called MiniDLNA and it lists the IP address of that jail.

Creating the Jail (New GUI)
1) You 'should' identify an IP address you will use for the MiniDLNA server or you can use DHCP if you must. For my example I will use 192.168.1.54.
2) In the FreeNAS GUI click on the Jails Icon
3) Click on Add Jail (Round yellow dot with a "+")
4) Click on the ADVANCED JAIL CREATION button
5) Enter the Jail Name MiniDLNA (Note: You could call it FreeBSD as you can use this jail for much more than just MiniDLNA, but for this purpose we will simply call it MiniDLNA)
a) Select the Release version you desire. AS of this writing I selected "11.2-RELEASE"
6) Now comes the tricky part, do you use DHCP or a static IP address.
a) DHCP: Click DHCP and skip to step 7 (Note: a few options will auto-select for you)
b) Static IP Address: Select "vnet0" for the IPv4 Interface (or whatever option you desire, some work, somoe don't). Fill in IPv4 address, netmask /24 (255.255.255.0), and default gateway. In my case the values are address: 192.168.1.54, netmask: /24 (255.255.255.0), default gateway: 192.168.1.1
7) Select Auto-start.
a) Now scroll down to the bottom of the screen and select "SAVE"
8) If this is the first time creating a FreeBSD jail then you will have a large download start up.
9) At the completion you should have a standard jail called MiniDLNA and it lists the IP address of that jail.
a) Once your jail is running you must Stop it to finish the configuration. On the right side of the jail (those three virticle dots), click it and select Stop.

Adding the Media Folder (Old GUI)
10) On the left panel of the GUI open Jails -> MiniDLNA -> Storage -> Add Storage
11) The first box should say MiniDLNA, leave that one alone
12) The Source you will need to locate your media to share
13) In the Destination box locate and select "/media"
14) It is recommended to not select Read-Only as some players will have issue with it however if you do select Read-Only and have a player having issues, go back and just change this.
15) Click OK

Adding the Media Folder (New GUI)
10) Click on the right side of the new jail (three verticle dots) and select "Mount points"
11) A new scree opens up called Mount ponts, on the right side is a yellow circle with a "+", click it
12) In Source you will need to locate your media to share
13) In the Destination box locate and select "/media" (Full path would look similar to this: "/mnt/pool/iocage/jails/MiniDLNA/media")
14) It is recommended to not select Read-Only as some players will have issue with it however if you do select Read-Only and have a player having issues, go back and just change this.
15) Click "SAVE"
a) We must start the jail again. On the left side of the GUI select "Jails"
b) On the right side of the GUI for your MiniDLNA jail select the three virticle dots and select "Start"

SSH into the Jail (Old & New GUI's)
You have several ways to get into the jail and I like to use Putty myself (you must have SSH enabled) but for this example we will use the built in GUI Shell. You can use the PASTE in the shell if you want to cut and paste the below commands if there is any doubt about spaces or format issues.

16) In the left hand pane select Shell and select the maximum window size you can read, for my screen it's 132x43.
17) Type "jls"
18) You should see a listing of jails by JID numbers, assuming JID 1 is MiniDLNA in this scenario...
19) Type "jexec 1 /bin/csh"
20) Type "pkg_add -r minidlna"
20a) Type "pkg install minidlna"
21) At this point MiniDLNA and support files will install
21a) At this point you will be asked to install, upgrade, reinstall, and/or remove software. You must type "y" to continue. This may occur several times and upgrade your FreeBSD jail to support the MiniDLNA program. If you fail to update then you may not have a working network connection.


Configuring MiniDLNA (Old & New GUI's)
22) Type "cd /usr/local/etc/" and you should be in that directory
23) Type "ee minidlna.conf" and you will now be editing the minidlna.conf file
24) Scroll down to the line where it says
Code:
media_dir=/opt
and change it to
Code:
media_dir=/media

25) Scroll down to the line where it says
Code:
#friendly_name=My DLNA Server
and change the line to (remove the # and change the name if you like)
Code:
friendly_name=MiniDLNA Server

26) Scroll down to the line where it says
Code:
#db_dir=/var/db/minidlna
and remove the "#"
27) Scroll down to the line where it says
Code:
#log_dir=/var/log
and remove the "#"
28) Press the ESCape key and Enter key twice to Leave and Save the changes.
29) Type "cd rc.d"
30) Type "ee minidlna"
31) Scroll down to the line where it says
Code:
command_args="-P $pidfile -u $minidlna_uid -f /usr/local/etc/minidlna.conf"
and add -R to make the line read
Code:
command_args="-R -P $pidfile -u $minidlna_uid -f /usr/local/etc/minidlna.conf"

32) Press ESCape and then Enter key twice to Leave and Save the changes.

Testing MiniDLNA (Old & New GUI's)
33) Type "service minidlna onestart" and you should get a message of Starting minidlna. Now go see if your DLNA compliant viewer can see your content, I use Windows Media Player (WMP) for testing purposes as I don't need to leave the computer when doing this test.

Make the MiniDLNA Run Normally (Old & New GUI's)
Now we must tell MiniDLNA to start when the jail is running.

34) Type "echo minidlna_enable="YES" >> /etc/rc.conf"
35) Type "exit"
36) Type "exit" which will close the shell.

Make the MiniDLNA Run Normally (Old GUI)
37) In the Jails Tab, select the MiniDLNA jail and at the bottom for the screen select Stop. Wait until the jail has stopped before continuing, this could take a minute or two depending on your system, be patient.
38) Verify the MiniDLNA is no longer running by testing your DLNA Device (WMP for me)
39) In the Jails Tab, select the MiniDLNA jail and at the bottom of the screen select Start. Wait about 30 seconds after it starts.
40) Verify MiniDLNA is working now and if it is, you are all done.

Make the MiniDLNA Run Normally (New GUI)
37) On the Jails screen, on the right side of the MiniDLNA jail select the three verticle dots and select Stop. Wait until the jail has stopped before continuing, this could take a minute depending on your system, be patient.
38) Verify the MiniDLNA is no longer running by testing your DLNA Device (WMP for me)
39) On the Jails screen, on the right side of the MiniDLNA jail select the three verticle dots and select Start. Wait about 30 seconds after it starts.
40) Verify MiniDLNA is working now and if it is, you are all done.


In order to rescan your database you have a few options:
1) Reboot your FreeNAS system
2) Stop the MiniDLNA Jail and then Restart it
3) Using a shell/SSH into the jail you can type "service minidlna restart"
4) You can use the script mentioned below only if you have the one Jail as it will stop other jails from running.


If you have any issues running this, before posting a question I request you start over again and use the cut & paste method to enter your commands. I have tested this out and it does work perfectly on "FreeNAS 9.3-STABLE-201505130355". Make sure you post the last step that worked and the step that failed along with the error you are seeing.

UPDATE: 10 January 2015
When you install the minidlna package it will be 1.1.1_5,1 which includes the kqueue support so when you add, delete, or rename a file in your library, the minidlna application will sense that and update the library database. This alleviates the issues of running a separate rescanning script.

UPDATE: 25 May 2015
Steps 20a and 21a were added because the package installer works differently in more recent versions of FreeNAS 9.3 and the FreeBSD jail must be updated. Also the newer version of MiniDLNA (1.1.4_1,1) now apparently supports faithful rescanning of the database, I'm glad kqueue is finally working well.

UPDATE: 1 October 2016
The entire set of instructions were tested with a clean installation of FreeNAS 9.10-1U1 and worked perfectly with one exception, a bug which prevents selecting the DHCP (step 6a). This jail bug has already been reported. Also, MiniDLNA (1.1.5_1,1) is now the current package.

UPDATE: 26 May 2017
Verified this procedure works fine with FreeNAS 11-RC3. No changes were made to the procedure.

UPDATE: 23 November 2018
Updated procedures to include FreeNAS 11.2. The proceduaral changes are purely GUI related, MiniDLNA is installed identical within the jail as the old GUI style.


-Mark
 
Last edited:

hervon

FreeNAS Experienced
Joined
Apr 23, 2012
Messages
304
Thanks pal. Works fine. This is the only 'plugin' I use on a regular basis. I'm glad to have it back.
 

joeschmuck

Old Man
Moderator
Joined
May 28, 2011
Messages
8,258
You're welcome and thanks for telling me about the typo, it's fixed now.
 

durdur

FreeNAS Experienced
Joined
Aug 22, 2012
Messages
284
Hi Mark,

I'm testing minidlna on FreeNAS 9.3 and there is a good surprise : when installing from the package : version 1.1.1 is compiled with kqueue patch, so database is automatically updated when new files are added on the dataset !
It seems to solve the biggest limitation of minidlna on FreeBSD.


But I have an other strange permission problem, as you know well minidlna and jails could you tell me if you are able to reproduce it ?
My medias files are on a dataset Medias with following owners and permissions : [nobody:GrpMedias 770], users who have access are in GrpMedias group.

In minidlna jail, the dataset Medias is mounted in /media, so inside the jail /media has the same [nobody:GrpMedias 770] permissions.

In order to allow medias files access to minidlna, I create GrpMedias group INSIDE the jail. This group has same GID in jail and in freeNAS based system. And finally I add dlna user to GrpMedias in jail. So minidlna should have access to medias files.... But here is the problem : log show "error accessing /media". If I change Media permission to 775 or 777 it works without problem.

I don't understand. I've done exactly the same procedure for Plex plugin without any problem. If I create a user "test" inside jail, add it to same GrpMedias group, I'm able to list /media folder and with another user toto, NOT in GrpMedias I get a "Permission denied" when trying to list /media.

So should I conclude this is a minidlna bug ?
 

joeschmuck

Old Man
Moderator
Joined
May 28, 2011
Messages
8,258
I don't know where to lay the blame but this has been an issue for a long time if I remember correctly for some people. If memory servers me correctly the problem resolved around the player as some of them try to create a temporary file on the server. That is off the cuff, I'm a bit medicated form some minor surgery.

I am glad to hear that kqueue is working now as well but I'll have to check it out myself and then if it also works for me, I'll update the first posting to reflect that information. That would be a major step in the right direction for folks who use MiniDLNA vice Plex for DLNA service.
 

BigJ

Newbie
Joined
Nov 20, 2014
Messages
28
Thanks for the detailed guide, works great. Just thought I share my experience with respect to step 20. The FreeNAS manual states,

"Warning do not use the pkg_add command in a FreeNAS® jail as it will cause inconsistencies in your package management database."

I used "pkg install" as suggested in the manual but it didn't work initially. On startup I got a message saying one of the required libraries (libiconv) wasn't installed. I then installed libiconv and if I read the packager installer correctly, an old version of libiconv was upgraded. Now it started up fine.

Thanks again.
 

joeschmuck

Old Man
Moderator
Joined
May 28, 2011
Messages
8,258
pkg install is replacing pkg_add and when we hit FreeNAS 10 (FreeBSD 10), pkg_add is gone.

Odd that using pkg install in step 20 didn't lend itself to include a required library.

But I'm glad you were able to get it done.
 

BigJ

Newbie
Joined
Nov 20, 2014
Messages
28
Odd that using pkg install in step 20 didn't lend itself to include a required library.
Hi Joeschmuck

Yes, I wasn't expecting that to occur. I thought I'd try to repeat the result so I deleted the jail and started again from scratch. This time "pkg install" worked without a hitch. Oh well, no big deal anyway.

Cheers
 
Last edited:

SmallGuy

FreeNAS Experienced
Joined
Jun 7, 2013
Messages
560
UPDATE: 10 January 2015
When you install the minidlna package it will be 1.1.1_5,1 which includes the kqueue support so when you add, delete, or rename a file in your library, the minidlna application will sense that and update the library database. This alleviates the issues of running a separate rescanning script.
I got 1.1.4_1,1, proceding the installation inside a standard jail with pkg updated:
Template: http://download.freenas.org/jails/9.2/x64/freenas-standard-9.2-RELEASE.tgz
Code:
portsnap fetch extract
make -C /usr/ports/ports-mgmt/pkg build deinstall install clean
pkg2ng
pkg update
pkg audit -F

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

Seems to be the latest: http://www.freshports.org/net/minidlna
 
Last edited:

joeschmuck

Old Man
Moderator
Joined
May 28, 2011
Messages
8,258
@SmallGuy
Does MiniDLNA run well? Does it automatically rescan your library if you make a change (add/delete/rename)?
 

SmallGuy

FreeNAS Experienced
Joined
Jun 7, 2013
Messages
560
@SmallGuy
Does MiniDLNA run well? Does it automatically rescan your library if you make a change (add/delete/rename)?
No something goes wrong with inotify:
The defaut value in /usr/local/etc/minidlna.conf is "inotify=yes";
Code:
# set this to no to disable inotify monitoring to automatically discover new files
# note: the default is yes
inotify=yes


and I got in /var/log:
Code:
root@miniDLNA:/var/log # more minidlna.log
[2015/01/25 16:33:55] minidlna.c:1029: warn: Starting MiniDLNA version 1.1.4.
[2015/01/25 16:33:55] minidlna.c:356: warn: Creating new database at /var/db/minidlna/files.db
[2015/01/25 16:33:55] minidlna.c:1077: warn: HTTP listening on port 8200
[2015/01/25 16:34:41] playlist.c:125: warn: Parsing playlists...
[2015/01/25 16:34:41] playlist.c:259: warn: Finished parsing playlists.
[2015/01/25 16:39:37] inotify.c:857: warn: kevent polling failure: Interrupted system call
[2015/01/25 16:39:37] inotify.c:857: warn: kevent polling failure: Interrupted system call
[2015/01/25 16:39:39] inotify.c:857: warn: kevent polling failure: Interrupted system call
[2015/01/25 16:39:39] inotify.c:857: warn: kevent polling failure: Interrupted system call
[2015/01/25 16:39:43] inotify.c:857: warn: kevent polling failure: Interrupted system call
[2015/01/25 16:39:47] inotify.c:857: warn: kevent polling failure: Interrupted system call
[2015/01/25 16:39:51] inotify.c:857: warn: kevent polling failure: Interrupted system call
[2015/01/25 16:39:55] inotify.c:857: warn: kevent polling failure: Interrupted system call
[2015/01/25 16:39:59] inotify.c:857: warn: kevent polling failure: Interrupted system call


I will try to disable inotify, and so disable the automatic discover of new files...
And I have to search around what means this warning...

[EDIT]http://lists.freebsd.org/pipermail/freebsd-ports/2014-June/093524.html
 
Last edited:

joeschmuck

Old Man
Moderator
Joined
May 28, 2011
Messages
8,258
You can disable those messages, the real trick is if the library is updated when you add/remove/rename a file.

To disable the warnings and only show errors do the following:
Open the minidlna.conf file and scroll down to line 31 (in my version), it will start with "#log_level=" and end with "=warn".
Change it to remove the "#" at the beginning and change the word "warn" to "error".
Now when you restart MiniDLNA you should only see error messages, not warnings.

The real trick is to ensure MiniDLNA actually works properly first before disabling the warning messages.

Let me know how this is going on.

EDIT: Even though you are getting the latest version of MiniDLNA, what are you gaining between the older version and the newer one besides error messages? This is actually a serious question. Are you gaining some added functionality or maybe compatibility with FreeNAS 10? I haven't looked into it and probably will not just because what I have actually works fine without any additional tweaking.
 
Last edited:

SmallGuy

FreeNAS Experienced
Joined
Jun 7, 2013
Messages
560
EDIT: Even though you are getting the latest version of MiniDLNA, what are you gaining between the older version and the newer one besides error messages? This is actually a serious question. Are you gaining some added functionality or maybe compatibility with FreeNAS 10? I haven't looked into it and probably will not just because what I have actually works fine without any additional tweaking.
You're right.
In fact I have try to install miniDLNA in a standard jail. And pkg was broken. That's why I have updated it. Then when I have installed minidlna, I got the 1.1.4_1,1 version.
The original configuration doesn't work at all with the inotify parameter set to 'yes' (the minidlna stop working on clients due to time out: DLNA 2101 error + above warning messages).
Set the value of inotify to 'no' fix the problem.
So I will keep this as is, but I agree there isn't any benefit...
FYI, I'm on 9.2.1.9 version of FreeNAS, probably off topic, sorry...
 
Last edited:

joeschmuck

Old Man
Moderator
Joined
May 28, 2011
Messages
8,258
If you delete your jail (or just delete MiniDLNA) and reinstall MiniDLNA per my instructions then you will have automatic updating of the files.db (library listing) when you add/delete/rename your files in your media directory.

OR

I have the correct plugin for 9.2.1.9 that automatically scans and runs fine. It's the same version as the one I mention in my first posting however it's in a plugin format. iXsystems created it for me for testing it out and it works fine. If you search for my MiniDLNA posting which I started, you will find more details on MiniDLNA and all the work I've done to try and make it work for people.

Here is the link to the MiniDLNA PBI (not sure how long this download will be available from this free file service) for FreeNAS 9.2.1.x.
 

BigJ

Newbie
Joined
Nov 20, 2014
Messages
28
Hi

For me, automatic library updates with version 1.1.4_1,1 on FreeNAS9.3 mostly works fine. I've had two instances where manual service restarts were required to pick up changes; manual rescans didn't seem to work for me. I'm glad the inotify warnings has come up as I've discovered my log file is stuffed full of them and its over 2 MBs in size just after a week of use.

Edit: Added which version of FreeNAS I'm running.
 

Bidule0hm

Server Electronics Sorcerer
Joined
Aug 5, 2013
Messages
3,710
Hi,

I was on FreeNAS 9.2.1.5 and I upgraded to 9.3-Stable yesterday. The minidlna plugin already installed worked (clients can connect and read media on the server) but the GUI was confused and showed that the plugin wasn't started. I had also some errors in the console :
Code:
freenas manage.py: [freeadmin.navtree:546] Empty data returned from http://192.168.0.4/plugins/minidlna/1/_s/treemenu
freenas manage.py: [plugins.utils:92] Couldn't retrieve http://192.168.0.4/plugins/minidlna/1/_s/status: No JSON object could be decoded

So I found this thread and I decided to delete the old plugin and jail, and then reinstall the proper version (which would have also allowed me to delete the ugly fix for the file rescan...).

So, I've followed the tuto and I'm stuck on step #20 :
Code:
root@minidlna:/ # pkg_add -r minidlna
Error: Unable to get ftp://ftp.freebsd.org/pub/FreeBSD/ports/amd64/packages-9-stable/Latest/minidlna.tbz: No address record
pkg_add: unable to fetch 'ftp://ftp.freebsd.org/pub/FreeBSD/ports/amd64/packages-9-stable/Latest/minidlna.tbz' by URL
root@minidlna:/ #


Does anyone can help me please?
 

joeschmuck

Old Man
Moderator
Joined
May 28, 2011
Messages
8,258
I suspect you do not have internet access but lets check it first... In the shell window type "ping google.com" and it should come back with data/packet times. If it does not then you need to either finish configuring your network for the FreeNAS machine or connect it to the internet.
 

Bidule0hm

Server Electronics Sorcerer
Joined
Aug 5, 2013
Messages
3,710
I can ping google from a normal freenas shell but not from the jail shell.

Edit: everything on the jail is configured exactly like before (when minidlna from the 9.2 install was working).
 
Last edited:

joeschmuck

Old Man
Moderator
Joined
May 28, 2011
Messages
8,258
Are you using DHCP or Static IPs and one the same subnet as your internet?
 
Top