1

Background

I have a BananaPi with Bananian, Apache2 and OwnCloud. Plugged into the Banana Pi is a NTFS-formatted HDD that gets mounted via ntfs-3g. I created five users on the system and there is a .NTFS-3G/UserMapping file inside the base-directory of the mounted partition, resulting in a UID/GID/SID mapping of the users and in automatically setting the permissions and acl options when the partition gets mounted. (www-data is not included in the UserMapping-file.) This partition contains a directory shares for Samba-shares and a directory owncloud/data. The owner of the whole owncloud-tree is root:root and permissions are 777.

Problem

In order for apache to access the data and owncloud to work, the owncloud/data directory has to belong to www-data:www-data. But if I try this:

chown -R www-data:www-data /media/hdd/owncloud/data

the ownership gets set to root:root, whatever owner the files and folders had before. This also happens for a single file:

chown www-data:www-data /media/hdd/owncloud/data/owncloud.log

and for every other place on the HDD:

chown -R www-data:www-data /media/hdd/shares/maximilian

But if I set the ownership to an arbitrary user, for example:

chown -R maximilian:maximilian /media/hdd/owncloud/data

it works perfectly fine!

Why can't I set the ownership to www-data then?

6
  • What does "id www-data" show? Jul 12, 2016 at 20:50
  • uid=33(www-data) gid=33(www-data) Gruppen=33(www-data)
    – S818
    Jul 12, 2016 at 20:53
  • 2
    I don't know whether you want to share the drive with Windows or not, but if you do, you might want to read tuxera.com/community/ntfs-3g-advanced/ownership-and-permissions for details on the UserMapping file works. If not, I suggest using the permissions or acl option while mounting instead of user mappings since it will make things simpler.
    – Munir
    Jul 13, 2016 at 2:08
  • @Munir: Thanks for the link. I added the following line (adapted to my case) for a generic mapping of users for whom no explicit mapping is defined to the UserMapping-file as pointed out on that site: ::S-1-5-21-1833069642-4243175381-1340018762-10000 Now the chown works fine. By the way, OwnCloud still showed me "Cannot create "data" directory". The reason was missing execute permissions for others on the path to the data folder as pointed out here.
    – S818
    Jul 13, 2016 at 11:03
  • @Munir: Furthermore, mounting the HDD with permissions also worked for the chown. Initially, my intention for using the UserMapping-file was to get data uploaded from Win machines to the shares folder via SMB to be owned by the acting user in Win instead of always root. It didn't work out, though. Anyway, I just wanted to know the reason for my problem at least. Now that it works, I can save myself the effort to add -o permissions to the mount-command every time. :-)
    – S818
    Jul 13, 2016 at 11:13

1 Answer 1

-2

The command

chown -R [user-name]:www-data /media/hdd/owncloud/data Where [user-name] replaced by the name of user maximilian

chmod -R 755 /media/hdd/owncloud/data

Will help out

7
  • Thanks, but unfortunately not. The first command did nothing as always and the second one removed the write permission for group and others as expected. Also executing the first command another time afterwards did nothing.
    – S818
    Jul 13, 2016 at 0:05
  • First You have to add user to group www-data? Then it may be possible.
    – Chirag
    Jul 13, 2016 at 0:59
  • adduser maximilian www-data
    – Chirag
    Jul 13, 2016 at 1:04
  • Or you should try all command from 'sudo' in beginning of every command if not running as root user
    – Chirag
    Jul 13, 2016 at 1:05
  • There is the user "www-data" inside the group "www-data". However, I temporary added "maximilian" to "www-data" with no effect. And, of course, I am acting as root the whole time.
    – S818
    Jul 13, 2016 at 1:05

You must log in to answer this question.

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