0

I have a program which creates some log directories using root next to the directory the user has given as argument to the script. I later chown them to my webservers user.

The problem is if all these are on an external drive then the directories do get created but the webservers user cannot write to them i.e files inside them. I guess this is mostly because the directory /media/<my-user> does not have execute permission for other users . External drive automounts at /media/<my_user>/external-drive.

I can mount with correct permissions via fstab or open nautilus using sudo and then change permissions but maybe there is a better solution. My applications end users are not experienced with ubuntu/linux.

I also tried adding the webservers user to plugdev but that didnt do the trick.

epsilon8
  • 121
  • 9
  • I would use the fstab route. I use that for USB external drive backups. Here's the previous Ask Ubuntu case that I used for this (I should note that I used the final method mentioned here mounted the drive rw for all users): https://askubuntu.com/questions/177825/how-to-mount-an-external-hdd – Mordoc Jul 20 '16 at 18:13

1 Answers1

0

I don't see how being external or internal makes any different: Linux will mount what you say him to mount. The difference here is if the HD is mounted by the system, it will be mounted in the way the system thinks it should be mounted and that might results in permission problems. I never use /media to mount external drives.

If you add the external HD to /etc/fstab it will be mounted with the permissions you want and considered like any other file system. This is an example of my own fstab:

#<file system>                            <mount point>   <type>   <options>                      <dump>  <pass>
UUID=a05fab8c-5c4c-42be-9898-830ec5ad45dc /here/external-drive  ext4    defaults,noatime,nofail,noauto 0       0

Assuming your log files are created under /here/external-drive/logs, it would be enough to change permissions to allow the webserver user to write there and everything should be fine.

Just remember adding nofail,noauto to your fstab or you will have problem each time the system reboots.