With the advent smart computing devices like ARM processor based Raspberry Pi there has been a significant rise is people setting up their home DLNA Servers for streaming their multimedia collections like movies, videos, pictures directly to their internet enabled or DLNA enabled smart TVs. Even almost all modern Android devices are capable to receiving DLNA streams.
MiniDLNA is one of the very popular DLNA server being used by raspbian users and also by users of Arch Linux and even a large community of Ubuntu users, mainly due to to it's fairly small size and simple ease of use. However there is some issue with MiniDLNA in automatically picking up changes / additions to the media_dir (Media Directory) i.e. more often it doesn't picks up any new file if added to the folder and updates the database which appears on your DLNA renderer like TV.
It generally throws the following warning in the logs:
[2012/10/19 18:35:41] inotify.c:195: warn: WARNING: Inotify max_user_watches [8192] is low or close to the number of used watches [4] and I do not have permission to increase this limit. Please do so manually by writing a higher value into /proc/sys/fs/inotify/max_user_watches.
While most of the solutions suggests setting up a cron job to rebuild the whole of the database at some specific time but hardly any of them address the fix to real issue or some says that the kernel or OS version doesn't supports the inotify feature. Also I don't like the idea of rebuilding the whole media library database every day or every time a new file is added, as ideally it should just add the new file in the media database Some of you might have even tried to update /proc/sys/fs/inotify/max_user_watches but probably failed with a error "E667: Fsync failed" at the vi.
Solution:
Edit sysctl.conf (A file for defining kernel parameters)
sudo nano /etc/sysctl.conf
Find and change as below if the following line exists or add at the bottom:
fs.inotify.max_user_watches=65536
Save the file Ctrl + X and Y(es)
Now run the below command, you should be able to see the values you have set:
sudo /sbin/sysctl -p
Finally restart MiniDLNA service and things should be working:
sudo service minidlna restart
Note: Make sure you have inotify enabled and a notify interval is set as per your requirement in /etc/minidlna.conf per the following settings
inotify=yes
notify_interval=300
This worked great for me... surprised there are no comments here yet... now I don't have to keep an "about to watch" folder on my Raspberry Pi and restart minidlna every 20 minutes. Awesome!
ReplyDeleteGlad that it was useful to you, and hopefully to many others.
Deleteyep, works on my rpi too :) thank you sir
ReplyDeleteWorked great on my rpi as well!
ReplyDeletei landed here again with my new banana pi.
ReplyDeletei forgot to say something it seems last time.
thx!
tried the above steps and also creating a link in /var/lib/minidlna to the directory you want monitored. (sudo ln -s /media/ExtHD/video /var/lib/minidlna/videos)
ReplyDeleteStill no luck with adding new files automatically to minidlna database :(
I have tried all the steps above on my banana pi, but unfortunatley the Auto adding new files still doesn´t work. Does anyone have some other/additional ideas?
ReplyDeletethx from germany; worked well for me too
ReplyDeleteIt's not working for me as well. I believe the inotify will work only with EXT file systems. I'm using an external NTFS hard drive.
ReplyDeleteI'm using external NTFS as well. works like a charm.
DeleteWorks like a charm! Took me 2 full days before I came across this post. Awesome! Thank you so much.
ReplyDeleteyou're my hero :)
ReplyDeletemy minidlna restarts every X seconds
ReplyDeleteX=notify_interval ... in my case is set to 300 like in this instructions...
problem is that i cant watch any movie now ... because very 5 minutes my minidlna restarts ... if i set value on bigger number like 36000 (10h) then i can watch in peace but it do not sync new movies in folder for 10 hours... verry disturbing ... any one have solution for this?
i'm running MiniDLNA on RPI2
Thanks for this solution. It is people like you that make learning things more enjoyable.
ReplyDeleteMiniDLNA status post fix...
ReplyDeleteAudio files: 0
Video files: 25
Image files: 14
Thanks mate!
why are you even mentioning `notify_interval`?, it has nothing to do with inotify
ReplyDeletePerfect. Thank you very much!!!!
ReplyDeleteI'm having trouble, have done every step here and that i can find elsewhere, i still don't seem to be getting an updated library?
ReplyDeleteChalk me up as another helped user. Thank you
ReplyDelete