Set data folder on external HDD (fresh installation)

Hi,
I started a fresh installation of Nextcloud on my RaspberryPi and I’m trying to set, during the initial wizard setup, to set the data folder on my external HDD.
I tried different solution that I found on “google it” but I got an error everytime “Can’t create or write into the data directory /media/pi/nextcloud/data”

Raspbian 9.9
Apache 2.4.25
PHP 7.0.33
MariaDB 10.1.38

Steps for the configuration:

  • create a mounting point for my external HDD on this path: /media/pi/nextcloud/
  • created a new folder: mkdir -p /media/pi/nextcloud/data
  • assigned permissions: chown -R /media/pi/nextcloud/data
  • assigned permissions: chmod 750 /media/pi/nextcloud/data

Output permissions using “ls -al”:
pi@server:/media/pi/nextcloud $ ls -al
total 28
drwxr-xr-x 4 root root 4096 Jul 10 23:25 .
drwx------ 3 pi root 4096 Jul 10 23:19 …
drwxr-x— 2 www-data www-data 4096 Jul 10 23:25 data
drwx------ 2 root root 16384 Jul 10 23:10 lost+found

I don’t what I need to do to solve this problem.
If someone could help me with this I appreciate.

Thank you.

I’m not sure what instructions you’re following, but this would normally be in the format:

chown -R user:group /media/pi/nextcloud/data

You should also check the permissions on your /media/pi/nextcloud/ directory, as it seems to be root:root.

Hi,

Yes, sorry I mistyped the command.
I put “chown -R www-data:www-data /media/pi/nextcloud/data” as you can seen on the output that I printed here.

Should the previous folder /media/pi/nextcloud/ with the same permissions as data folder?

Like this “chown -R www-data:www-data /media/pi/nextcloud/“ ?

Thank you.

Hi,

just an update to this thread, I already changed the permissions on the previous folder “/media/pi/nextcloud” using this command:

chown -R www-data:www-data /media/pi/nextcloud

But I get the same error when I try to finish the initial wizard, pointing data folder to “/media/pi/nextcloud/data”

Error:

Can’t create or write into the data directory /media/pi/nextcloud/data

Any more suggestions about this error?

Thank you.

Hi,
I already solved the problem.
I had to give permission on previous folder.

chown -R www-data:www-data /media/pi/

Now I complete the wizard installlation.

Thank you.