This is a very brief article or rather a reminder to myself, about how to install MiniDLNA on Ubuntu Server 20.04. I always knew this piece of software by it’s old name MiniDLNA, but apparently it was renamed and is now called ReadyMedia. There don’t seem to be many changes below the hood though.
MiniDLNA is a light-weight media server using the DLNA protocol. Through MiniDLNA a library of media files is created which allows a user to very conveniently browse through the files and start audio and video playback. Most SmartTVs and Android phones support DLNA out of the box.
Since MiniDLNA is available as a package on Ubuntu the easiest way to get the work done is by installing the corresponding package. Who would have guessed.
$> sudo apt install minidlna
Before starting the
minidlna service, the configuration file
/etc/minidlna.conf should be edited, most importantly to tell
minidlna where to find the media files.
Just open /etc/minidlna.conf and walk through the file line by line, the comments are quite clear and tell you exactly what to do.
The most important part is to set the path to the media folders, which should look something like this:
... media_dir=A,/mnt/nas/music media_dir=V,/mnt/nas/movies media_dir=P,/mnt/nas/photos media_dir=A,/home/hugoriusz/Music media_dir=P,/home/hugoriusz/Pictures media_dir=V,/home/hugoriusz/Videos ...
The media directories are simply listed one after another. The letters indicate which type of media can be found in a folder: A for audio, V for video, P for pictures and PV for both pictures and videos.
If the media library should be updated in real-time the setting
inotify=yes should be used.
Also note that the port given in
minidlna.conf (default TCP 8200) must be allowed through the firewall.
After the configuration file is to your liking, the
minidlna service can be started. This is one of the advantages of using
minidlna directly from the official PPA repository, as everything comes prepared to run as a service.
$> sudo service minidlna restart
There was no immediate error, but checking the output of
top shows that no
minidlna process is running. This should be the case, as
minidlna should start scanning the media folders and add any files it finds to it’s media library.
By checking the log it becomes clear what’s missing.
[2021/01/24 20:52:31] minidlna.c:1060: warn: Starting MiniDLNA version 1.2.1.
[2021/01/24 20:52:31] minidlna.c:292: fatal: ERROR: Failed to open sqlite database! Exiting…
[2021/01/24 20:55:07] minidlna.c:1009: error: Unable to set db_path [/var/cache/minidlna] ownership to 112: Operation not permitted
[2021/01/24 20:55:07] minidlna.c:1060: warn: Starting MiniDLNA version 1.2.1.
[2021/01/24 20:55:07] minidlna.c:292: fatal: ERROR: Failed to open sqlite database! Exiting…
The database folder
/var/cache/minidlna does not have the right permissions. Easy enough to fix. The user and group minidlna where automatically created when the package was installed it seems, at least I can’t recall creating them myself.
sudo chown -R minidlna:minidlna /var/cache/minidlna
Let’s try again.
$> sudo service minidlna restart $> sudo service minidlna status ● minidlna.service - LSB: minidlna server Loaded: loaded (/etc/init.d/minidlna; generated) Active: active (running) since Sun 2021-01-24 20:59:12 UTC; 53s ago Docs: man:systemd-sysv-generator(8) Process: 62766 ExecStart=/etc/init.d/minidlna start (code=exited, status=0/SUCCESS) Tasks: 3 (limit: 18764) Memory: 222.5M CGroup: /system.slice/minidlna.service ├─62778 /usr/sbin/minidlnad -f /etc/minidlna.conf -P /run/minidlna/minidlna.pid -r └─62781 /usr/sbin/minidlnad -f /etc/minidlna.conf -P /run/minidlna/minidlna.pid -r
Alright, it seems to work now. The
minidlna service is running and the output of
top should show
minidlna crunching away some considerable CPU percentage, as it is busy to initialize it’s media library. This can take several hours if there are a lot of media files, or just a few minutes (or seconds) if there is only a miniscule number of files to scan.
In order to automatically launch the
minidlna daemon after each boot, the
minidlna service must be enabled (maybe this happens automatically, I don’t know, I’m used to doing this manually…).
$> sudo systemctl enable minidlna