4

I connected a HDD to USB port, then Raspbian allow me to mount the unit.
So I can access to logical drive with this path: /media/pi/PICTURES-HDD.

Then I installed a DLNA server (serviio) to view the HDD content from TV, smartphone, notebook... etc.

The DLNA server runs as a service. The user is dlna-user.
The dlna-user has dlna-group as primary group, and it is member of media group.

So I run this command to apply required permission to allow dlna-user to access to the PICTURES-HDD:

# chown -R root:media /media
# chmod -R 777 /media

I think that it is right to permit dlna-user to view the /media folder and relative childs files and folders.

But it do not works: when I try to navigate inside the folder with dlna-user user I receive "Permission denied":

  • change operative user:
    $ sudo -u dlna-user hash
    now I using the dlna-user.
  • go to /media folder:
    $ cd /media
    it works.
  • go to inside pi folder:
    $ cd pi
    returns this: bash: cd: pi: Permission denied.

I don't understand...

1 Answer 1

5

This happens because you have mount helpers which mount the storage devices with the identity of the user holding the current session on your machine. If you have a GUI and log in as pi, that's the user who will own the mounted devices.

Changing permissions on /media/pi will not achieve anything as the mount helpers will either reset the permissions or remove the folder altogether and recreate it from scratch if they find it's unusable by the pi user.

A common solution for mounting as a given user is to use /etc/fstab:

UUID=0123456789ABCDE   /mnt/pictures   ext4   defaults,uid=dlna-user,gid=dlna-group

You can view the UUIDs of your drive volumes using blkid.

The above example will mount the device automatically at boot. If this is not desired, you can add noauto and user, and later execute mount /mnt/pictures as dlna-user when you need the volume mounted.

Another option you can try is to use pmount (again, as dlna-user) without changing /etc/fstab, but I'm not sure if it will work.

2
  • 1
    If you use fstab this way, the partition will be automounted at boot normally (by which I mean, not a fuser mount courtesy of the DE). For an ext4 fs, that means unless you override them, the permissions on the contents will be as actually set in the mounted filesystem. Ie., it may be preferable to not use uid and gid.
    – goldilocks
    Commented Nov 27, 2019 at 15:48
  • @goldilocks Yeah, I put the permission there in case the OP has something else for a filesystem. They may change the name but forget to put the uid/gid in. Commented Nov 28, 2019 at 7:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.