16

I have a secondary hard drive that is mounted as /media/Media and I would like to user a folder called Videos located on that drive that I would like to share the videos located on this folder out via minidlna. I have minidlna working with /home/jonathan/Videos which is on my smaller drive and would like to instead move the videos to the larger drives.

However after I edit my minidlna.conf to point to the /media/Media/Videos folder and do a sudo service minidlna force-reload to reload the database I get a permssions error.

Can someone point me to the correct permissions I need to set on this folder?

6
  • In order to help we need the exact error you get. We also need to know how you formatted, how you mounted your media drive, and where your minidlna.conf points to. Otherwise its just guessing here. The minidlna way to rescan its library is given in my answer - no need to force-reload.
    – Takkat
    Commented Mar 11, 2013 at 15:20
  • When I go to start mindlna after changing my minidlna.conf to piont to the video folder /media/media/Videos it tells me permission denied. The drive is a secondary disk and is mounted by the system when I login/turn on the computer so not sure what you mean about how it is mounted
    – jjesse
    Commented Mar 11, 2013 at 17:10
  • What I was thinking is, that irrespect of permissions of your Video directory minidlna should have read access as it runs as root. This is not true for the minidlna database which is stored in /var/lib/minidlna owned by group minidlna. Therefore we need to run the rescan -R as user minidlna, or we may put this library to a different place (see mindlna.conf -> db_dir=). I have mine in my HOME.
    – Takkat
    Commented Mar 11, 2013 at 18:10
  • So minidlna works as long as I use /home/jjesse/Videos/ as my directory things work fine, but if point it to /media/media/videos I get the permssions error, hence the question about what permissions i need on /media/media/videos
    – jjesse
    Commented Mar 16, 2013 at 0:49
  • On my systems here we need read permissions for minidlna, of course. These may depend on the user/group you run minidlna with. This usually is root but it can also be run as minidlna, or as any user, depending entirely on your individual setup.
    – Takkat
    Commented Mar 16, 2013 at 9:01

9 Answers 9

17

I tried following the examples in this thread but still could not get it to work. I ended up stumbling on this article here: Running minidlna on Ubuntu and followed it step by step and I now have the media on my second drive being served through minidnla. If any one else struggles I suggest you follow his process.

I have quoted his text in case his page ever disappears.


He installed a service called minidlna which is supposed to allow streaming of media. However, it didn’t like the permissions on his chosen folder. The path is /media/jw/drive2/foo.

jw@FooPC:~$ sudo service minidlna restart
* Restarting DLNA/UPnP-AV media server minidlna
[2014/07/23 21:03:30] minidlna.c:594: error: Media directory "/media/jw/drive2/foo" not accessible [Permission denied]

He pointed it to a folder in his home folder and it liked that just fine, but not the 2nd drive that holds the media.

He tried setting the user as me in the conf file and in the default file. But eventually He discovered he had to set the user as “root” to make it work.

He opened terminal and entered ...

sudo gedit /etc/default/minidlna

...and edited the file...

# User and group the daemon should run as
USER=”root”
#GROUP=”minidlna”

...then saved and back to terminal and entered...

sudo gedit /etc/minidlna.conf

... and edited the file...

# Specify the user name or uid to run as.
user=root

He restarted the service using...

sudo service minidlna restart

... in terminal and this time there was no error about permissions.


I hope that helps someone as it helped me. If it helps you then please visit his page and leave him a comment like I did so he knows that his page is helping!

UPDATE:

This works straight away but if you power off the machine and then restart it the second drive is not served by the minidnla server until you run:

sudo service minidlna restart

Getting it to work from bootup is a user-mode drive problem and can be fixed by adding the drive to fstab. The downside is that the system will not boot automatically if the drive is not plugged in, as it will annoyingly demand to retry or ignore before continuing to boot.

An alternative to adding the drive to fstab is to restart the minidlna service at reboot from cron:

sudo crontab -e

then add the next line at the end of the file:

@reboot sleep 60 && sudo service minidlna restart
1
  • for me, I had to change the user to "root", in the systemd unit file to work.
    – SdSaati
    Commented Jun 30, 2023 at 22:23
10

/media/* is automounted with udisks. If it's NTFS or FAT, only the active user gets access to it, so the minidlna user cannot access it.

It's silly that udisks has the permissions hardcoded, there's a bug report about that: https://bugs.launchpad.net/ubuntu/+source/udisks/+bug/682589

If one mounts the disk with sudo mount /dev/sdb1 /mnt or with /etc/fstab, he can put whatever permissions he wants so that minidlna can read it.

So for home PCs one easy workaround is to edit /etc/default/minidlna, and either specify that minidlna will run as root, or as the user that usually mounts those disks.

# User and group the daemon should run as
USER="root"
#GROUP="minidlna"

If you specified a user account instead of root, also run sudo chown -R user:user /var/lib/minidlna

To rescan the library after the changes, run sudo service minidlna force-reload

And a note to myself, rather than adding media_dir= entries in /etc/minidlna.conf, I prefer creating symlinks under /var/lib/minidlna, e.g.:

sudo ln -sf /media/alkisg/mydisk/Photos /var/lib/minidlna/Photos

...because that way I get an extra level of hierarchy when browsing the media folders in DLNA clients.

1
  • Thanks, I finally got my NTFS partition to work with minidlna. I already mounted my partition via fstab, but had the wrong options. Since the NTFS Partition is not used by a windows system or similar I just used the following options to mount it in fstab: default,umask=0000. Works like a charm!
    – Bernd
    Commented Jan 11, 2015 at 19:10
5

type
sudo chown -R minidlna:minidlna /media/Media

in order to give minidlna ownership of all files and folders contained in Media

then restart and force-rescan the server

IMPORTANT
Start minidlna as root!

sudo minidlna

to rescan library after adding files to your media drive use

sudo service minidlna stop
sudo minidlna -R
sudo service minidlna restart

to see if it's up

service minidlna status
8
  • Thanks so much I made the changes and still getting the same error [2013/03/20 12:37:50] minidlna.c:474: error: Media directory "/media/Media/Videos/" not accessible! [Permission denied]
    – jjesse
    Commented Mar 20, 2013 at 17:01
  • 1
    that's very odd...I'll have to look at my own set up again because I've got minidlna running, with my external drive as media partition and I think this was the only change I had to make
    – Daniel W.
    Commented Mar 20, 2013 at 22:46
  • 1
    one thing you could do just to verify that ownership was indeed changed is to type 'ls -lh /media' and see if the ownership (3rd and 4th item in the list) is set to 'minidlna' also do this for '/media/Media' and '/media/Media/Videos' to see if the changes were applied recursively
    – Daniel W.
    Commented Mar 31, 2013 at 10:58
  • Thanks for this, it looks like the change wasn't recursive? Now the ls -lh shows minidlna as the owner and the group. but still getting a permission denied on this. Not quite sure what's going on
    – jjesse
    Commented Mar 31, 2013 at 18:42
  • oh man I think I missed the obvious here...you seem to need to start minidlna as root. I just got the same errors as you did on my setup after rebooting it for the first time in 2 month. you have to type 'sudo minidlna' that should do the trick (providing that all the right permissions are still set on the folders)
    – Daniel W.
    Commented Apr 9, 2013 at 17:40
3

I had the same problem, and tried to fix it using this post. But I didn't want root to run the daemon.

Note:

  • I am also connecting a removable disk in userspace as (without using fstab).
  • I am running Ubuntu 16.04.02 LTS

So I edited /etc/default/minidlna to contain

USER=<user>
GROUP=<group>

then /etc/minidlna.conf to contain

user=<user>

I also had to change permissions to allow my user

chown <user>:<group> /var/cache/minidlna
chown <user>:<group> /run/minidlna

Then restart the service

sudo service minidlna restart
1
  • 1
    This worked for me. My system uses systemd, so I had to change the user in /lib/systemd/system/minidlna.service instead of /etc/default/minidlna, and reload the configuration with sudo systemctl daemon-reload afterwards.
    – SomeDude
    Commented Feb 13, 2022 at 14:40
3

I found another solution: the parent of the media folder has to be accessible to minidlna too. I tried running minidlna as root, and ProtectHome=read-only in the systemctl minidlna.service file but none of this worked.

In my case my videos were in media_dir=V,/srv/share/videos/library.

I had done chmod -R a+xr /srv/share/videos/library but was still getting the Permission Denied message.

After I did chmod o+xr /srv/share/videos it all worked, with user=minidlna.

Hope this helps someone.

2
  • nice one !!!!!!!
    – Mr.P
    Commented Aug 19, 2022 at 17:49
  • The easiest way to check if this will help you is to run a check with sudo -u minidlna ls -al /your_path/
    – Ondrej
    Commented Feb 4, 2023 at 9:37
1

I was trying to run MiniDLNA as an alternative storage area for HDHomeRun RECORD (using NAS config in HDHomeRun SETUP).

I thought Samba was conflicting when I rebooted and my DLNA server was no longer working. Turns out I never set firewalld to have an open port 8200, I had just turned it off and forgotten to disable the service (probably thinking I would do it properly later and forgetting).

I'm using Fedora 27, BTW.

For some reason MiniDLNA reports media directory as being not accessible if your port is not open. Example --

Before turning off firewalld:

# systemctl status minidlna

systemd[1]: Started MiniDLNA is a DLNA/UPnP-AV server software.
minidlna.c:620: error: Media directory "/home/local/Downloads" not accessible [Permission denied]
minidlna.c:620: debug: Using locale dir '/usr/share/locale' and locale langauge en_US.UTF-8/en_US.UTF-8
minidlna.c:1048: warn: Starting MiniDLNA version 1.2.1.

After turning off firewalld:

# systemctl status minidlna

<root xmlns="urn:schemas-upnp-org:device-1-0"><specVersion><major>1</major><minor>0</minor></specVersion><dev
minidlnad[4401]: MS_MediaReceiverRegistrar</eventSubURL><SCPDURL>/X_MS_MediaReceiverRegistrar.xml</SCPDURL></service></service
minidlna.c:1302: debug: HTTP connection from 192.168.1.190:65260
minidlnad[4401]: clients.c:332: debug: Client found in cache. [Generic UPnP 1.0/entry 1]
minidlnad[4401]: upnphttp.c:889: debug: HTTP REQUEST: GET /icons/sm.png HTTP/1.1
minidlnad[4401]: Connection: Keep-Alive
minidlnad[4401]: User-Agent: User-Agent: Microsoft-DLNA DLNADOC/1.50
minidlnad[4401]: Host: 192.168.1.186:8200
minidlnad[4401]: [1B blob data]
minidlnad[4401]: upnphttp.c:1391: debug: 
Sending small PNG icon

I'm not sure why it would report the media directory as being inaccessible because of a port being blocked, that seems like strange behavior to me. But disabling the firewall was all I did for it to start working again.

0

I realize this is an older question but if you fstab the external drive with the defaults,user as options and then sudo chown -cR $USER:minidlna /media/(your_mount point_here). This should maintain the ownership and group through reboots as well as give the default minidlna group that the server is run with group access to the files.

0

I ran into the same problem on a NAS I try to create. I think the /etc/init.d/minidlna script should not:

if [ -z $GROUP ]; then
   GROUP=$USER
fi

But do a

if [ -z $GROUP]; then
   GROUP=$(id -gn $USER)
fi

Because the primary group of the user may differ from the user. Especially when you want users to share you want a group they share to be the primary group of minidlna too.

-1

To let miniDLNA rescan its library we may issue the following commands:

sudo service minidlna stop    # stop minidlna
sudo -u minidlna minidlna -R  # rescan the library
sudo service minidlna start   # restart minidlna

Note that with default library settings the second line needs to be run under the user minidlna in order to let minidlna have access to this library later.

Depending on your settings you may have defined a location for the library other than default /var/lib/minidlna. Then we may need different permissions.

1
  • Thank you for the answer, however it doesn't address my concern at all. I'm looking for the permissions for the folder/drive
    – jjesse
    Commented Mar 11, 2013 at 14:54

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .