From ArchWiki
Revision as of 18:30, 15 September 2012 by Sambul13 (talk | contribs) (File System and Localization)
Jump to navigation Jump to search

MiniDLNA is server software with the aim of being fully compliant with DLNA/UPnP clients. The MiniDNLA daemon serves media files (music, pictures, and video) to clients on a network. Example clients include applications such as totem and xbmc, and devices such as portable media players, Smartphones, Televisions, and gaming systems (such as PS3 and Xbox 360).

MiniDLNA (ReadyDLNA) is a simple, lightweight alternative to MediaTomb, but has fewer features. It does not have a web interface for administration and must be configured by editing a text file.


Install minidlna from the official repositories.


The MiniDLNA daemon can be run as either a global (config:/etc/minidlna.conf) or per-user instance (config:user-defined), these are the necessary common settings:

#network_interface=eth0         # Self-discovers if commented (at times necessary to set)
media_dir=A,/home/user/Music    # Mounted Media_Collection drive directories
media_dir=P,/home/user/Pictures # Use A, P, and V to restrict media 'type' in directory
friendly_name=Media Server      # Optional
db_dir=/var/cache/minidlna      # MiniDLNA Media_DB dir needs to be un-commented
log_dir=/var/log                # Log dir needs to be un-commented
inotify=yes                     # 'no' for less resources, restart required for new media
presentation_url=http://www.mylan/index.php     # or use your device static IP


MiniDLNA scans your Media_Collection at startup and creates or updates database Media_DB browsable via media players. Set database cache and logging dirs in config, so the db and album art cache won't be re-created on every restart. By default MiniDLNA runs as nobody user as set in /etc/conf.d/minidlna, unless you set your own. That user needs rw permissions to cache and log directories you specified in conf. Create the required directories and chown them to nobody:nobody.

# mkdir /var/{cache,log}/minidlna
# chown nobody:nobody /var/{cache,log}/minidlna

You can login as MiniDLNA user and create symbolic link in the default Media_DB directory to a mounted in the system external drive, just make sure to set MiniDLNA user rw permissions and other mount options for the drive in fstab and/or udev automount rules if mounted after boot:

# ln -s /media/MyDrive/Media_DB /var/cache/minidlna

MiniDLNA includes an initscript to start it as a global daemon. Be sure to add minidlna to rc.conf to have it loaded at boot.


Create the necessary files and directories locally and edit the configuration:

# mkdir -p ~/.minidlna/cache
# cd ~/.minidlna
# cp /etc/minidlna.conf .
# $EDITOR minidlna.conf

Configure as you would globally above but these definitions need to be defined locally:


This is a local daemon script to start and stop MiniDLNA as a regular user:

# Start and stop the MiniDLNA daemon


# Required program(s)
for p in ${req_progs[@]}; do
  hash "$p" 2>&- || \
  { echo >&2 " Required program \"$p\" not installed."; exit 1; }

dmn_strt () {
  minidlna -f "$cnf" -P "$pid" > $log 2>&1 &

dmn_stop () {
  if [ "$(pgrep -x minidlna)" ]; then
    killall -9 minidlna && sleep 2 && \
    echo " Stopped MiniDLNA daemon"
    echo " MiniDLNA is not running"

dmn_rscn () {
  minidlna -R -f "$cnf" -P "$pid" > $log 2>&1 &

help     () {
  echo " ${0##*/} <start|stop|rescan> - start,stop,rescan the MiniDLNA daemon"

case $1 in
  start   ) # Start daemon
            dmn_strt || { echo " Failure in starting daemon"; exit; }
            echo " Started MiniDLNA daemon" ;;
  stop    ) # Stop daemon
            dmn_stop ;;
  rescan  ) # Rescan for new files (new file detection only works when
            # minidlna is running)
            dmn_rscn ;;
  *       ) # Display usage if no parameters given

Load daemon on Login

A .desktop file in ~/.config/autostart will do this:

[Desktop Entry]
Comment=Server to stream media over network
Exec=/home/$USER/.scripts/minidlna-daemon start

Make the file executable:

# chmod +x ~/.config/autostart/minidlna.desktop

Automatic Media_DB Update

Kernel adds one inotify watch per each folder/subfolder in Media_Collection Directories set in /etc/minidlna.conf to monitor changes thus allowing MiniDLNA to update Media_DB in real time. When MiniDLNA is run as a regular user, it does not have the ability to change the kernel's inotify limits. If default number of inotify watches is non-sufficient to have MiniDLNA monitor all your media folders, increase inotify watches through sysctl (100000 should be enough for most uses):

# sudo sysctl fs.inotify.max_user_watches=100000

To have it permanently changed, add to /etc/sysctl.conf

# Increase inotify max watchs per user for local minidlna
fs.inotify.max_user_watches = 100000"

inotify performance may depend on device type. Some don't rescan media drives on a consistent basis or at all. If files are added/deleted to monitored media directories, they may not be noticed until the device DLNA client is restarted.

Check inotify updates via MiniDLNA presentation_url by comparing files count. If it doesn't change, make sure the user running MiniDLNA has rw access to the DB folder. If the issue persists, copy or download new files first to a non-watched by inotify Downloads folder on the same drive, and then move them to appropriate media folders, since lengthy media files copying or downloading may confuse inotify.

You can also clean or rebuild MiniDLNA DB manually after stopping MiniDLNA daemon, or analyze its debug output (Ctrl+C to exit):

/etc/rc.d/minidlna stop
minidlna clean
minidlna -R
minidlna -d

Other details

Additional details that may need to be considered.


If using a firewall the the ssdp (1900/udp) and trivnet1 (8200/tcp) ports will need to be opened. For example, this can be done with arno's iptables firewall by editing firewall.conf and opening the ports by doing:


File System and Localization

When keeping MiniDLNA Media_DB on an external drive accessible in both Linux and Windows, choose proper file system for it. NTFS preserves in Windows its Linux defaults: rw access for root user and UTF8 font encoding for file names, so media titles in your language are readable when browsing Media_DB in media players, since most support UTF8. If you prefer Vfat (FAT32) for better USB drive compatibility with older players when hooked directly, or your Media_Collection drive is Vfat and has folder & file names in your local language, MiniDLNA can transcode them to UTF8 charset while scanning folders to Media_DB. Add your codepage and font encoding or transcoding charset to Media_Collection and Media_DB drives' mount options, i.g. codepage=cp866,iocharset=utf8, and rw permissions for all users, since Vfat doesn't preserve Linux access permissions:

UUID=6140-75F7 /media/MyDrive/Media_DB vfat user,rw,async,noatime,umask=111,dmask=000,cp866,utf8=true 0 0

Make sure the required codepage for your locale is available in the system and enabled (like ru_RU.CP866), i.e. was included in system config when ArchLinux release was compiled, or consider recompiling the release to add it:

ls /usr/share/fonts/encodings

MiniDLNA lists Movies and Photos by file name in its DB, and Music entries by ID3 tags instead of file names. If Music collection wasn't tagged in UTF8 but in local encoding, MiniDLNA might not identify and transcode it correctly to UTF8 for display in media players, or the original tags codepage(s) may be absent in your system, so the tags won't be readable even when media file names are. In this case consider re-tagging your collection to UTF-16BE or UTF-8 encoding with an ID3 tag converter.

Picking the "right" file system for your Media_Collection is a trade-off: XFS and EXT4 show fast read/write for HDs and lower CPU load critical for small Plug Computers with attached storage, while NTFS is most compatible with Windows. As file fragmentation affects playback, store your Movies on a non-system drive formatted in XFS (prevents fragments), NTFS (fragment resistant and easy to defrag), or EXT4 (uses large file extents), and avoid EXT3 or less resistant FAT32. For smaller Flash drives with seldom fragmented Music and Photo files, FAT32 (VFAT) and EXT4 show faster writes with less CPU load, but EXT4 affects memory wear due to journaling, and less compatible with media players. Proper block alignment and mount options can greatly accelerate flash speed.

Media Handling

MiniDLNA was developed for small devices, and doesn't generate movie thumbnails to lower processor load and DB built time. It uses either media thumbnails present in the same media folder, or if none extracts them where present from media containers like MP4 or MKV allowing embedded Album Art tags, but not AVI. Users can make and add own 160 x 160 pixels JPG thumbnails to media folders, and miniDLNA will scan them to its Media_DB. Larger thumbnails will be resized by miniDLNA that slows scan. If each movie is saved in a separate folder, follow thumbnail naming conventions in MiniDLNA config. For a single media folder with multiple movies, each thumbnail name should match its movie file name (<file>.cover.jpg or <file>.jpg). To handle MS Album Art thumbnail names with GUID, add * to the end "AlbumArt_{*".jpg . MiniDLNA will show on screen only chosen type of media files (i.e. Movies), but won't list their thumbnail files for cleaner output.

When viewing photos, progressive and/or lossless compression JPG may not be supported by your player via DLNA. Also resize photos to "suggested photo size" by the player's docs for problem free image slideshow. DLNA spec restricts image type to JPG or PNG, and max size to 4096 x 4096 pixels - and that's if the DLNA server implementation supports the LARGE format. The next size limit down (MEDIUM) is 1024 x 768, so resizing may help to show photos correctly.

To decrease system load, MiniDLNA doesn't transcode on the fly unsupported media files into supported by your player formats. When building Media_DB, it might not correctly identify whether certain formats are supported by your player, which may play via UPnP a broader formats choice. DLNA standard is quite limiting UPnP subset in media containers and codec profiles allowed. If you don't see on TV screen or can't play some media files listed in Media_DB, try connecting to your media player via USB for their playback. MiniDLNA might not support choosing audio tracks, subtitles, disk chapters, list sorting, and other advanced playback features for your player model.