Can't create or write into the data directory :(

Hello,
I get the error:
Can’t create or write into the data directory

I know there are already a few posts out there about this topic, but I was never able to resolve the problem after looking through most of them.

I want to install Nextcloud of a Raspberry Pi 4 where Ubuntu 21.04 is installed.
My plan is to place to the data directory on an external drive. The drive is formatted as ext4.
I already tried to apply these commands:
sudo chown -R www-data:www-data /media/user/Lexar/Nextcloud
sudo chmod -R 755 /media/user/Lexar/Nextcloud/
sudo chmod -R g+rwx /media/user/Lexar/Nextcloud/
and the directory does belong to www-data,
but still my efforts were to no avail.

After failing miserably for many long hours to resolve this issue,
I would be quite grateful for any help.
Since I am very new to Linux would be extra thankful for easy to understand explanation and maybe even what certain commands do, so I can learn to resolve such errors better my self.

Thank you in advance!

You need to adjust config.php as well

I edited the config.php, but it does not help.

How did you mount the external drive?

The drive is connected per USB.

How did you mount it?

I’m sorry if this reply won’t be helpful, too.
It’s just, that I find the concept of “mount a disk” still strange, since I have only begun recently to move away from Windows.
I only connected the disk per USB and formatted it to ext4. Now the directory of the disk is /media/user/Lexar/
Do I have to necessarily mount it manually to work with Nextcloud?

Add the mount point to /etc/fstab and mount it as user www-data

1 Like

You just made my day!!!
After so many days not understanding WHY… trying out all complicated stuff, and making sure www-data owns everything etc, this little remark of yours simply worked.
THANK YOU!