External Storage Help Needed

I’m looking for some basic help on getting external sorage to work on my nextcloud 17.0 instance.

I have read several posts here, but the advice and circumstances given seem to be for very specific instances where I think that my instance is very typical.

  1. I have one user named “mshelby.” This user also has admin privileges in Nextcloud.

  2. My nextcloud instance is hosted on a Raspberry Pi with the latest Raspbian version running.

  3. My Raspbian system has a root user, and only one general user also named ‘mshelby.’

  4. I am aware that the Raspbian user and the nextcloud user are technically not the same since one is a system wide user, and one is a nextcloud only log-in user.

I have mounted an external usb drive. with system-wide user, mshelby as the owner. I am able to create and delete files on the system while logged in as this user on Raspbian. i.e from the command line I can create, edit and delete files on the drive as the mshelby user on Raspbian.

  1. While logged into nextcloud as mshelby user with admin privs I created a local external storage mount, and incleded both ‘admin’ user and ‘mshelby’ user as having permission to access it. But my nextcloud user (also mshelby) cannot write to it. I get the “…you don’t have permission…” error.

  2. So my issue seems pretty straight forward. My drive is a FAT32 drive. But I lack the proper permissions to access it and can’t figure out why.

Please Help!
Here is my FSTAB line:

/dev/sda1 /media/usb vfat user,iocharset=ascii,fmask=0022,exec,conv=b,gid=1001,umask=007,suid,codepage=437,errors=remount-ro,dev,relatime,shortname=mixed,dma$

Just check the user name to whom belongs your Nextcloud. Do e.g.:

ps -ef | grep -E "apache2|ngnix"

For me it is www-data

ps -ef | grep apache2
www-data 20722 20721  0 11:36 ?        00:00:17 /usr/sbin/apache2 -k start
www-data 20723 20721  0 11:36 ?        00:00:36 /usr/sbin/apache2 -k start

Now you can try to access to your external drive as this user, e.g. List files and create files:

sudo -u www-data ls -la  /media/usb

and try to create file and see if you can:

sudo -u www-data touch /media/usb/testfile.txt

Basically you can refer to this:

Thanks for your reply, but I’m not sure that told me anything new or helped solve my issue.

Again, outside of nextcloud I have an attached and automounted USB drive. Outside of next loud I can access it and right to it. When opporating as a nextcloud use within nextcloud I cannot write to it.
Yes, the user is www-data, but how does that help me? Do I need to add my nextcloud user to the group www-data?
Seems be like I can’t be the only one working on this.

You means all NC users admin and mshelby? Or only mshelby and admin can create files?

Stupid question, but did you check that you mount it as not read only?

But did you checked that user www-data has an access to this USB drive as I mentioned above?
Basically there are only 2 things could happen:

  1. Your user www-data simply has no access to this folder on OS level. That you can check via commands above.
  2. Your apache or php config is harden so that they are not allowed to access any other folders (or exachtly USB) except your e.g. /var/www/. About this I’m not sure, but check if there is an .htaccess file exist in a /media/usb.