You don’t have permission to upload or create files here

Will check that tonight. Thanks.
The cloud storage needs to avoid the 8GB SD card (from which the raspi boots) so I expected to have to do this at first run of NextCloud. I will search for the option to set external local storage.

The best option is to restore the settings of the webserver to the default data folder.

Then attach the external drive to your usb

Run

lsblk
to find the usb driver reference e.g. /dev/usb?

Partition at will (remember 4 primary and unlimited extended)

Format with parted or fdisk or use the LVM tools to convert such into logical volumes.

Mount the partition/s with

mount /dev/usb? /media/data

Edit the /etc/fstab to mount the partition/s at boot.

NextCloud - enable the app external storage

NextCloud - in the admin settings, select the external storage and mount the drive as data and remember to put in your mount point.

As you changed the data folder, it is best to force nextcloud to rescan by doing this in Ubuntu

cd /var/www/nextcloud
sudo -u www-data php console.php files:scan --all

Generally I like to restart apache or reboot to see if everything holds.

Just a tip to take into consideration, unlike servers, SoCs don’t have adequate air pressure cooling to run 247 so consider to embark on power management and wakeonlan features if possible on your Pi. This will enable you to boot your Pi remotely, then sync with NextCloud and on idle time, the Pi will shutdown.

1 Like

Well, thank you for the extended help. I already had a drive mounted and I added the external storage app, pointing it at the new location etc. Went all smoothly. What is not clear is if the external storage has now taken over from the intial location which was /var/www/html/nextcloud/data. Obviously, I can check when I start uploading. The 1st time I went with the default location, the server crashed after it filled the local SD quickly, which isn’t all that unreasonable. I’m trying it out now.

Sorry to ask more questions: where does it store the synced data now? The folder under /var/www/html/nextcloud/data/ and /media/pi/HD1TB/nextcloud/data/ are both empty folders.

Check out what you have set in your config/config.php as data-folder. If it is a mounted device, you can check with df -h if it is mounted at all.

I admit, I don’t get this:
The config.php lists

datadirectory => /var/www/html/nextcloud/data
overwrite.cli.url => http://192.168.0.9/nextcloud

The external storage app inside the nextcloud admin pages points to

Folder name: local1TB
External storage: local
Authentication: none
Configuration: /media/pi/HD1TB/nextcloud/data

This path exists with r/w right for www-data.

My synchromised files appear in the folder : /var/www/html/nextcloud/data

If I sync more files, the SD card of my raspi2 will fill up and the server will crash (an experiment I have successfully tried before).

What I want is to tell nextcloud to use the external HD for data storage only. How do you do this?

Does www-data have all the required permissions, also in the parent folders?
sudo -u www-data ls -ls /media/pi/HD1TB/nextcloud/data

You might have a good point there. I am not 100% sure but I believe to set the access rights I used something like this:

cd /media/pi/HD1TB/nextcloud/
chmod -R 755 www-data data
chown -R www-data:www-data data

i.e. not the full path. I will try this tonight. Sorry, my Linux knowledge is still not comprehensive after years of using it.
Thank you for your help.

1 Like

Ok.

My folder rights
/media/pi/HD1TB/nextcloud/data

drwxr-xr-x 3 root root 4096 Jan 22 22:35 media
drwxr-x—+ 4 root root 4096 Jan 25 22:50 pi
drwxr-xr-x 4 root root 4096 Jan 22 23:05 HD1TB
drwxrwxr-x 3 www-data www-data 4096 Jan 22 23:05 nextcloud
drwxrwxr-x 2 www-data www-data 4096 Jan 22 23:05 data

I don’t understand why www-date is not be able to write to nextcloud and the data folders. I use the same chmod and chown commands to set the folder rights for the nextcloud installation path on /var/www/html/.

I started again with a fresh install. The same error message when you finish the installation
Can’t create or write in the data directory :unamused:

1 Like

Now that I’ve run the command

sudo chmod -R 777 /media/

giving all rights to all, nextcloud starts writing on the

/media/pi/HD1TB/nexcloud/data

folder. So the only conclusion I can take is that the www-data user is not running the webserver on my Rp2.

Why 777 vs 755?

That would be my question as well. I do not understand why opening all the doors (777) was required to get Nextcloud to write to the essential external HD attached to my RPi. I am not a Linux guru.

Had a very similar problem. Running NextCloud 12 through the NextCloudPi integration. Had everything set up on a mounted external HDD. Set up a smb share for other pis to be able to write to the data folder, would not work. then could also not browse to it through the terminal. only changing permissions to 777 worked. interestingly could browse folder in samba share view, just not write to it.

imo you should have used: (for debian based distros)

sudo chown -R www-data:www-data /media/data
sudo chmod -R 0750 /media/data

Only sudo can change the owner from root to www-data

Important: For consecutive commands eg mkdir you need to be user www-data eg:

sudo -u www-data bash
cd /media/data
mkdir /asdf

or

sudo -u www-data mkdir /media/data/asdf

There seems to be a problem in the docs, which I’m trying to fix atm.


Just a remark. … In absolutely now way I’d use a 777 permission on folders or 666 for files. Everyone knows that’s :imp:

With the RPI, there is an even bigger problem with the access rights. …

Since the SD card is probably small, we need to move everything to the attached drive. using the nextCloudPiPanel eg:

  • nc-backup-auto
  • nc-backup
  • nc-database
  • nc-datadir
  • ???

Which then contains the app and the data. … So only the /data/ directory should be writeable by www-data

The rest needs to be root … I did test this with nc-backup and it worked as root.

www-data can’t get in here!

Just wanted to say thank you for this post, that reallllly saved me a lot of time! Using the same setup with raspberry pi and mounted my drive to /var/nextcloud/data with my external, got it to work!

1 Like

After copying files I used: sudo -u www-data php /var/www/nextcloud/occ files:scan --all
I had the same problem, so i used this command again and now all permissions are set correctly.

3 Likes

There are already different use cases, different systems, … let’s close this issue. Some might still find an answer to their permission problems. If there are still issues, please use a new topic. We could even think about creating an howto article out of this …