Minidlna Media Server through Debian Entware

This guide is obsolete now, use this one instead

This is for mipsel devices, like RT-N16, RT-N66U/R, RT-AC66U/R
Advantages: easy to update without waiting for asus, easy to apply patches, very stable with zero crashes at least for me on RT-AC66U, I enabled movie thumbnails with filmstrip (will take a little bit longer to scan db) and bookmarks for resuming videos on samsung E & F series.
 
Let's start
0 - Install one of Merlin's firmware from here
1 - Turn off Media server from router ui 192.168.1.1 and insert an usb drive in to the router, should be formatted as ext2 or ext3
2 - Setup entware from this guide

3 - Open terminal and input the next command:

cd /opt

4 - Download prepared debian with all necesary libs and decompress

wget -c -O debian-minidlna-1.1.4-2.tgz http://goo.gl/pXqSJQ
tar -xvzf ./debian-minidlna-1.1.4-2.tgz

5 - Download start-stop script, in this script is a path EXT_DIR to your media folder witch will be mounted in debian as /mnt, mine is /mnt/sda1/Media and if your disk has a label change sda1 from CHROOT_DIR with your disk label, modify the script to match your settings with vi or nano editor, use this command nano /opt/etc/init.d/S99debian

wget -c -O /opt/etc/init.d/S99debian http://goo.gl/FnWro0
chmod a+rx /opt/etc/init.d/S99debian
opkg install nano

6 - Download services-list that will run in chrooted debian, for now is only minidlna but if you want to install another packages in debian like transmission-daemon, you need to add transmission start-stop script name, ex. S50transmission

wget -c -O /opt/etc/chroot-services.list http://goo.gl/gFdbdr
chmod a+rx /opt/etc/chroot-services.list

7 - Reboot router

reboot

8 - Go to 192.168.1.1:8200 (this is the default router ip, modify to your router ip if you change it previously) and see how minidlna is creating db, press refresh on your browser for progress.
If all numbers are 0 (zero) after some time, you forget to set the right path to your media folder, read again point 5 carefully

minidlna

9 - If you want to enter chrooted debian to install other packages or to modify some options, use this commands:

mount -o bind /dev/ /opt/debian/dev/
mount -o bind /proc/ /opt/debian/proc/
mount -o bind /sys/ /opt/debian/sys/
chroot /opt/debian /bin/bash

To exit, just type

exit

To update from a previous version follow this steps:

1. Stop minidlna

/opt/etc/init.d/S99debian stop

2. Download latest version:

wget -c -O /opt/debian/var/tmp/minidlna_1.1.4-2_mipsel.deb http://goo.gl/ApgCPG
wget -c -O /opt/debian/var/tmp/minidlna.conf http://goo.gl/9n27yN

3. Enter chrooted debian

mount -o bind /dev/ /opt/debian/dev/
mount -o bind /proc/ /opt/debian/proc/
mount -o bind /sys/ /opt/debian/sys/
chroot /opt/debian /bin/bash

4. Input next commands:

dpkg -r minidlna
rm -r /opt/minidlna
cd /var/tmp
cp -r minidlna.conf /etc
chmod 777 /etc/minidlna.conf
dpkg -i minidlna_1.1.4-2_mipsel.deb

5. Exit debian

exit

6. Start minidlna

/opt/etc/init.d/S99debian start

7. Enjoy your media :)

To completely uninstall chrooted debian:
1. Stop minidlna

/opt/etc/init.d/S99debian stop

2. Verify if external folder is not mounted, output should be empty, if not - stop again.

Very important!!! If continue and external folder is mounted, all media files inside will be deleted.

ls -l /opt/debian/mnt
/opt/etc/init.d/S99debian stop

3. Delete debian folder

rm -r /opt/debian

4. Delete debian startup script

rm /opt/etc/init.d/S99debian

5. Delete chrooted services list

rm /opt/etc/chroot-services.list

This is how it looks like on my Samsung TV

Minidla-bookmarks

 

  • pascal

    i have followed above manual but my DB remains empty, i have several options but i can't get it to work

    • If you set the right path to your media folder in S99 debian script, should work.
      Outside debian, stop server
      /opt/etc/init.d/S99debian stop
      Remove minidlna db folder
      rm -r /opt/debian/opt/minidlna
      Start server again
      /opt/etc/init.d/S99debian start
      If still not working, post here outputs from:
      mount
      uname -a
      df
      free
      cat /opt/etc/init.d/S99debian

      • pascal

        ok for the movies i have on the hard disk i got it working, but i also have pictures and music in the same folder and those are not found.

        here you have the outcome of your requests:
        admin@RT-N66U-2A98:/tmp/home/root# mount
        rootfs on / type rootfs (rw)
        /dev/root on / type squashfs (ro)
        proc on /proc type proc (rw)
        tmpfs on /tmp type tmpfs (rw)
        devfs on /dev type tmpfs (rw,noatime)
        sysfs on /sys type sysfs (rw)
        devpts on /dev/pts type devpts (rw)
        /dev/mtdblock4 on /jffs type jffs2 (rw,noatime)
        usbfs on /proc/bus/usb type usbfs (rw)
        /dev/sda1 on /tmp/mnt/mediaserver type ext3 (rw,nodev,noatime,data=ordered)
        devfs on /tmp/mnt/mediaserver/debian/dev type tmpfs (rw,noatime)
        proc on /tmp/mnt/mediaserver/debian/proc type proc (rw)
        sysfs on /tmp/mnt/mediaserver/debian/sys type sysfs (rw)
        /dev/sda1 on /tmp/mnt/mediaserver/debian/mnt type ext3 (rw,nodev,noatime,data=ordered)

        admin@RT-N66U-2A98:/tmp/home/root# uname -a
        Linux RT-N66U-2A98 2.6.22.19 #1 Tue Dec 23 00:30:59 EST 2014 mips GNU/Linux

        admin@RT-N66U-2A98:/tmp/home/root# df
        Filesystem 1K-blocks Used Available Use% Mounted on
        /dev/root 27712 27712 0 100% /
        tmpfs 119836 4944 114892 4% /tmp
        devfs 119836 0 119836 0% /dev
        /dev/mtdblock4 3072 412 2660 13% /jffs
        /dev/sda1 1922857776 481463452 1343718756 26% /tmp/mnt/mediaserver
        devfs 119836 0 119836 0% /tmp/mnt/mediaserver/debian/dev
        /dev/sda1 1922857776 481463452 1343718756 26% /tmp/mnt/mediaserver/debian/mnt

        admin@RT-N66U-2A98:/tmp/home/root# free
        total used free shared buffers
        Mem: 239672 174220 65452 0 1648
        -/+ buffers: 172572 67100
        Swap: 0 0 0

        admin@RT-N66U-2A98:/tmp/home/root# cat /opt/etc/init.d/S99debian
        #!/bin/sh

        PATH=/opt/bin:/opt/sbin:/sbin:/bin:/usr/sbin:/usr/bin
        # Folder with Debian Squeeze
        CHROOT_DIR=/tmp/mnt/mediaserver/debian
        # Some folder outside of sandbox, will be mounted to /mnt folder in Debian
        # Leave commented if not needed
        EXT_DIR=/tmp/mnt/mediaserver/media/

        CHROOT_SERVICES_LIST=/opt/etc/chroot-services.list
        if [ ! -e "$CHROOT_SERVICES_LIST" ]; then
        echo "Please, define Debian services to start in $CHROOT_SERVICES_LIST first!"
        echo "One service per line. Hint: this is a script names from Debian's /etc/init.d/"
        exit 1
        fi
        MountedDirCount="$(mount | grep $CHROOT_DIR | wc -l)"
        start() {
        if [ $MountedDirCount -gt 0 ]; then
        echo "Chroot'ed services seems to be already started, exiting..."
        exit 1
        fi
        echo "Starting chroot'ed Debian services..."
        for dir in dev proc sys; do
        mount -o bind /$dir $CHROOT_DIR/$dir
        done
        [ -z "$EXT_DIR" ] || mount -o bind $EXT_DIR $CHROOT_DIR/mnt
        for item in $(cat $CHROOT_SERVICES_LIST); do
        chroot $CHROOT_DIR /etc/init.d/$item start
        done
        }

        stop() {
        if [ $MountedDirCount -eq 0 ]; then
        echo "Chroot'ed services seems to be already stopped, exiting..."
        exit 1
        fi
        echo "Stopping chroot'ed Debian services..."
        for item in $(cat $CHROOT_SERVICES_LIST); do
        chroot $CHROOT_DIR /etc/init.d/$item stop
        sleep 2
        done
        mount | grep $CHROOT_DIR | awk "{print $3}" | xargs umount -l
        }

        status() {
        if [ $MountedDirCount -gt 0 ]; then
        echo "Chroot'ed services is running"
        else
        echo "Chroot'ed services is stopped"
        fi
        }

        case "$1" in
        start)
        start
        ;;
        stop)
        stop
        ;;
        restart)
        stop
        sleep 5
        start
        ;;
        status) status
        ;;
        *)
        echo "Usage: $0 (start|stop|restart|status)"
        exit 1
        ;;
        esac

        echo Done.
        exit 0

        thanx in advance!!!

      • All settings are ok but you didn't enabled SWAP, it's very important, this will crash your minidlna server.
        Enable swap
        Stop server
        Remove minidlna folder
        Start server again

        I will post another tutorial with minidlna through debian wheezy v7.7

        Swap at point 9
        https://www.hqt.ro/how-to-install-debian-wheezy-mipsel/

      • pascal

        i just enabled the SWAP file but i still have some question, i have a folder called media in which i have movies, pictures and music but only the movies are visible in the scan.

        what do i have to do to solve this?

      • No audio or picture is shown on 192.168.1.1:8200 or in your dlna player list?
        Look for some error in /opt/minidlna/minidlna.log

      • pascal

        no nothing, i tried to check that log but i can't find it

      • /opt/minidlna/minidlna.log is inside debian
        From entware is /opt/debian/opt/minidlna/minidlna.log
        If no error there, try to set log to debug by editing /opt/debian/etc/minidlna.conf
        log_level=debug

        Minidlna server should be stopped while editing conf file

      • pascal

        it very strange i always get below error message:

        admin@RT-N66U-2A98:/# cd /opt/debian/opt/minidlna/
        -sh: cd: can't cd to /opt/debian/opt/minidlna/

      • Try step by step, maybe you deleted minidlna folder
        cd /opt
        cd /opt/debian...

      • pascal

        it looks you are right, i have deleted the mninidlna folder

        admin@RT-N66U-2A98:/tmp/mnt/mediaserver/entware# cd /opt/debian
        admin@RT-N66U-2A98:/tmp/mnt/mediaserver/entware/debian# ls
        bin dev home media opt root selinux sys usr
        boot etc lib mnt proc sbin srv tmp var

      • No,
        ls -l /opt/debian/opt

      • pascal

        admin@RT-N66U-2A98:/tmp/mnt/mediaserver/entware/debian# ls -l /opt/debian/opt
        drwxrwxrwx 2 admin root 4096 Sep 10 16:22 tmp

      • You only have tmp folder, minidlna is missing because was not started again after you deleted it.
        Have you disabled built in minidlna from router menu?

      • pascal

        yes it is disabled on the router

      • Ok, then start debian version with
        /opt/etc/init.d/S99debian start

      • pascal

        admin@RT-N66U-2A98:/# /opt/etc/init.d/S99debian start
        Chroot'ed services seems to be already started, exiting...

      • Stop and start again
        /opt/etc/init.d/S99debian stop
        /opt/etc/init.d/S99debian start

      • pascal

        admin@RT-N66U-2A98:/# /opt/etc/init.d/S99debian stop
        Stopping chroot'ed Debian services...
        Stopping minidlna:.
        Done.
        admin@RT-N66U-2A98:/# /opt/etc/init.d/S99debian start
        Starting chroot'ed Debian services...
        Starting minidlna:.
        Done.
        admin@RT-N66U-2A98:/#

      • Should be ok now, go to 192.168.1.1:8200
        If only video files are scanned, see log for errors
        cat /opt/debian/opt/minidlna/minidlna.log

      • pascal

        i can only see video files

        admin@RT-N66U-2A98:/# cat /opt/debian/opt/minidlna/minidlna.log
        cat: can't open '/opt/debian/opt/minidlna/minidlna.log': No such file or directory

      • You did something wrong from the beginning!
        Post:
        cat /opt/debian/etc/minidlna.conf
        cat /opt/debian/etc/init.d/S98minidlna-debian

      • pascal

        admin@RT-N66U-2A98:/# cat /opt/debian/etc/minidlna.conf
        # port for HTTP (descriptions, SOAP, media transfer) traffic
        port=8200

        # network interfaces to serve, comma delimited
        #network_interface=eth0

        # specify the user account name or uid to run as
        #user=jmaggard

        # set this to the directory you want scanned.
        # * if you want multiple directories, you can have multiple media_dir= lines
        # * if you want to restrict a media_dir to specific content types, you
        # can prepend the types, followed by a comma, to the directory:
        # + "A" for audio (eg. media_dir=A,/home/jmaggard/Music)
        # + "V" for video (eg. media_dir=V,/home/jmaggard/Videos)
        # + "P" for images (eg. media_dir=P,/home/jmaggard/Pictures)
        # + "PV" for pictures and video (eg. media_dir=PV,/home/jmaggard/digital_camera)
        media_dir=/mnt

        # set this to merge all media_dir base contents into the root container
        # note: the default is no
        merge_media_dirs=yes

        # set this if you want to customize the name that shows up on your clients
        friendly_name=Debian-1.1.4

        # set this if you would like to specify the directory where you want MiniDLNA to store its database and album art cache
        db_dir=/opt/minidlna

        # set this if you would like to specify the directory where you want MiniDLNA to store its log file
        log_dir=/opt/minidlna

        # set this to change the verbosity of the information that is logged
        # each section can use a different level: off, fatal, error, warn, info, or debug
        #log_level=general,artwork,database,inotify,scanner,metadata,http,ssdp,tivo=warn

        # this should be a list of file names to check for when searching for album art
        # note: names should be delimited with a forward slash ("/")
        album_art_names=Cover.jpg/cover.jpg/AlbumArtSmall.jpg/albumartsmall.jpg/AlbumArt.jpg/albumart.jpg/Album.jpg/album.jpg/Folder.jpg/folder.jpg/Thumb.jpg/thumb.jpg

        # set this to no to disable inotify monitoring to automatically discover new files
        # note: the default is yes
        inotify=yes

        # set this to yes to enable support for streaming .jpg and .mp3 files to a TiVo supporting HMO
        enable_tivo=no

        # set this to strictly adhere to DLNA standards.
        # * This will allow server-side downscaling of very large JPEG images,
        # which may hurt JPEG serving performance on (at least) Sony DLNA products.
        strict_dlna=no

        # default presentation url is http address on port 80
        #presentation_url=http://www.mylan/index.php

        # notify interval in seconds. default is 895 seconds.
        notify_interval=900

        # serial and model number the daemon will report to clients
        # in its XML description
        serial=12345678
        model_number=1

        # specify the path to the MiniSSDPd socket
        #minissdpdsocket=/var/run/minissdpd.sock

        # use different container as root of the tree
        # possible values:
        # + "." - use standard container (this is the default)
        # + "B" - "Browse Directory"
        # + "M" - "Music"
        # + "V" - "Video"
        # + "P" - "Pictures"
        # + Or, you can specify the ObjectID of your desired root container (eg. 1$F for Music/Playlists)
        # if you specify "B" and client device is audio-only then "Music/Folders" will be used as root
        #root_container=.

        # always force SortCriteria to this value, regardless of the SortCriteria passed by the client
        #force_sort_criteria=+upnp:class,+upnp:originalTrackNumber,+dc:title

        # maximum number of simultaneous connections
        # note: many clients open several simultaneous connections while streaming
        max_connections=50

        # Suport to Movie Thumbnail generation. To use this option, thumbnail generation must be enable at compile time.
        enable_thumbnail=yes

        # The width of the thumbnail image. Large images takes more time to generate. To use this option, thumbnail generation must be enable at compile time.
        thumbnail_width=160

        # Thumbnail Image quality. To use this option, thumbnail generation must be enable at compile time.
        thumbnail_quality=8

        # Should the thumbnail have a film strip? To use this option, thumbnail generation must be enable at compile time.
        enable_thumbnail_filmstrip=yes

      • pascal

        admin@RT-N66U-2A98:/# cat /opt/debian/etc/init.d/S98minidlna-debian
        cat: can't open '/opt/debian/etc/init.d/S98minidlna-debian': No such file or directory

      • pascal

        i think this is the logs you wanted:

        admin@RT-N66U-2A98:/tmp/mnt/mediaserver/entware/debian/etc/init.d# cat /opt/debi
        an/etc/init.d/S98minidlna
        #!/bin/sh

        # description: Startup/shutdown script for MiniDLNA daemon

        MINIDLNA=/usr/local/sbin/minidlnad

        ARGS=' -f /etc/minidlna.conf'
        DESC=$PROCS
        PATH=/opt/sbin:/opt/bin:/opt/usr/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

        test -f $MINIDLNA || exit 0
        test -d $MIDIADIR || exit 0

        . /lib/lsb/init-functions
        case "$1" in
        start) log_daemon_msg "Starting minidlna" ""
        start-stop-daemon --start --quiet --pidfile /var/run/minidlna/minidlna.pid --startas $MINIDLNA -- $ARGS $LSBNAMES
        log_end_msg $?
        ;;
        stop) log_daemon_msg "Stopping minidlna" ""
        start-stop-daemon --stop --quiet --pidfile /var/run/minidlna/minidlna.pid
        log_end_msg $?
        ;;
        restart|reload|force-reload)
        log_daemon_msg "Restarting minidlna" ""
        start-stop-daemon --stop --retry 5 --quiet --pidfile /var/run/minidlna/minidlna.pid
        start-stop-daemon --start --quiet --pidfile /var/run/minidlnad.pid --startas $MINIDLNA -- $ARGS $LSBNAMES
        log_end_msg $?
        ;;
        status)
        status_of_proc -p /var/run/minidlna/minidlna.pid $MINIDLNA minidlnad && exit 0 || exit $?
        ;;
        *) log_action_msg "Usage: /etc/init.d/minidlna {start|stop|restart|reload|force-reload|status}"
        exit 2
        ;;
        esac
        exit 0

      • Yes, was this one.
        ls -l /opt/etc/
        cat /opt/etc/chroot-services.list

      • pascal

        admin@RT-N66U-2A98:/tmp/mnt/mediaserver/entware/debian/etc/init.d# ls -l /opt/et
        c/
        -rwxrwxrwx 1 admin root 11 Dec 29 17:16 chroot-services.list
        drwxr-xr-x 2 admin root 4096 Dec 29 17:14 init.d
        -rw-r--r-- 1 admin root 580 Dec 29 17:11 ld.so.cache
        -rw-r--r-- 1 admin root 0 Dec 18 11:58 ld.so.conf
        -rw-rw-rw- 1 admin root 105 Dec 29 17:11 opkg.conf
        -rwxr-xr-x 1 admin root 457 Dec 29 17:11 profile

      • pascal

        admin@RT-N66U-2A98:/tmp/mnt/mediaserver/entware/etc# cat /opt/etc/chroot-services.list
        S98minidlnaadmin@RT-N66U-2A98:/tmp/mnt/mediaserver/entware/etc#

      • All seams ok, dunno what more I can do.
        Reboot router

        Working on another tutorial, like I said previously

      • Use this tutorial https://www.hqt.ro/minidlna-upnp-media-server-through-debian-wheezy-mipsel-optware/ it's for Optware but steps are the same.

        Remove old installation first:

        To completely uninstall chrooted debian:
        1. Stop minidlna

        /opt/etc/init.d/S99debian stop

        2. Verify if external folder is not mounted, output should be empty, if not - stop again.

        Very important!!! If continue and external folder is mounted, all media files inside will be deleted.

        ls -l /opt/debian/mnt

        /opt/etc/init.d/S99debian stop

        3. Delete debian folder

        rm -r /opt/debian

        4. Delete debian startup script

        rm /opt/etc/init.d/S99debian

        5. Delete chrooted services list

        rm /opt/etc/chroot-services.list

  • 1.1.4 - Released 26-Aug-2014
    --------------------------------
    - Add magic container infrastructure.
    - Add magic containers for 50 recent items for each category.
    - Fix bad null termination in AAC parsing.
    - Fix requests for the last byte of a file, which affected MKV playback on Philips TV's.
    - Support 64-bit time_t values.

SoftEther VPN Running on AsusWRT Routers
Minidlna UPnP Media Server through Debian Jessie Arm
How to Mount Samba Shares inside Chrooted Debian
Nginx Web Server with PHP Support through Optware-NG
Minidlna UPnP Media Server through Debian Jessie Arm
How to Mount Samba Shares inside Chrooted Debian
Spreed WebRTC server and web client
Asterisk VoIP Server running on AsusWRT Routers
SoftEther VPN Running on AsusWRT Routers
NZBGet through Entware
Minidlna UPnP Media Server through Debian Jessie Arm
NetData System Monitor Entware

SUBSCRIBE

To be notified by email when a new tutorial is posted :)

Thanks for Subscribing! I'll keeping you up-to-date with latest tutorials!

Something went wrong, try again...