Failing to setup nextcloud with external ext4 drive

Hi guys.

I’m trying to set up nextcloud on my Raspberry Pi. I’ve managed to set up everything according to this tutorial (running ubuntu 20.04 LTS on the machine):
https://pimylifeup.com/raspberry-pi-nextcloud-server/

Seing that this works, I tried to rerun the installing (deleting my admin user in the DB) process only with the external drive instead. I’ve followed the instructions here:
https://sebroy.com/blog/technical/nextcloud-external-primary-storage/

But I get an error during the setup process saying “Cannot create or write into the data directory”. Here is my ls output:

ubuntu@ubuntu:/mnt$ ls -la
total 12
drwxr-xr-x  3 root root 4096 Apr 13 07:23 .
drwxr-xr-x 20 root root 4096 Apr 13 07:32 ..
drwxr-xr-x  2 root root 4096 Apr 13 07:23 BIG

and the relevant line in my fstab file
UUID="809E18FE9E18EE82" /mnt/BIG ext4 defaults,auto,users,rw,nofail 0 0

Now, one thing that is a bit weird, is that before the fstab file mounted my drive in /media/ubuntu/ folder. The mount still happens (after reboot).

ubuntu@ubuntu:/mnt$ ls -la /media/ubuntu/BIG
total 136716
drwxr-xr--  3 ubuntu   ubuntu        4096 Apr 13 07:12 .
drwxr-x---+ 3 root     root          4096 Apr 12 14:11 ..
-rw-r--r--  1 root     root     139983015 Mar 21 13:09 latest.tar.bz2
drwxr-x---  2 www-data www-data      4096 Apr 13 07:12 nextcloud_data

I’ve tried also that path, and it has failed as well.

So what I’m I doing wrong?


Side comment, I don’t know why I cannot see the nextcloud_data and the tar file in the /mnt/BIG path. I guess that the issue is related.

Change the user:group ubuntu:ubuntu to www-data:www-data for . (directory BIG)
Set:
chown www-data:www-data /media/ubuntu/BIG

If it not helps post your settings in /path/to/nextcloud/config/config.php

Thanks. I’ve tried and I get the same error.

My /var/www/nextcloud/config/config.php file is rather boring:

<?php
$CONFIG = array (
  'instanceid' => 'ocnju38kxfkf',
);

Here is my current status ownership:

ubuntu@ubuntu:/media/ubuntu$ ls -la
total 12
drwxr-x---+ 3 root     root     4096 Apr 12 14:11 .
drwxr-xr-x  3 root     root     4096 Apr 13 05:27 ..
drwxr-xr--  3 www-data www-data 4096 Apr 13 07:12 BIG

You also must set
chown www-data:www-data /media/ubuntu

But it think it is not possible because you have mounted it not correctly.
You must mount it that www-data can read/write/execute.

config.php:
Is your config.php only 4 lines long?
That is not correct.
Read example parameters here.

Your installation:
I think your installation (your link above) is ok.
It is ok to install “normal” packages on an Pi.
But there are also images e.g. NextcloudPi (installation guide).
I don’t have a Pi. But i wouldn’t know which installation type i would prefer.

Nope, that is still not it. I’m still in the set-up page (deleted the webpage folder and created a new one).

Here is a snapshot of the page
image

And my current permission status

 ls -la
total 12
drwxr-x---+ 3 root     root     4096 Apr 12 14:11 .
drwxr-xr-x  3 root     root     4096 Apr 13 05:27 ..
drwxr-xr--  3 www-data www-data 4096 Apr 13 07:12 BIG

About using NextCloudPi, I tried it, but my machine wouldn’t load at all. I’ll try to download a new copy of the OS and format it again.

The user www-data can not read/write/execute this directory. Perhaps you can set:
chmod 755 /media/ubuntu
Then check command ls -al again.

Please no. I think we can better solve your actual problem.

OK, chmod 755 gave some progress. I’ve finished the install and I can log into the system, but I cannot actually do anything. My permission status:

root@ubuntu:/media/ubuntu/BIG/nextcloud_data/yotam# ls -la
total 12
drwxr-xr-x 3 www-data www-data 4096 Apr 13 10:31 .
drwxr-x--- 4 www-data www-data 4096 Apr 13 10:26 ..
drwxr-xr-x 2 www-data www-data 4096 Apr 13 10:26 cache

root@ubuntu:/media/ubuntu/BIG/nextcloud_data# ls -la
total 224
drwxr-x--- 4 www-data www-data   4096 Apr 13 10:26 .
drwxr-x--- 3 www-data www-data   4096 Apr 13 07:12 ..
-rw-r--r-- 1 www-data www-data    542 Apr 13 10:26 .htaccess
-rw-r--r-- 1 www-data www-data      0 Apr 13 10:26 .ocdata
drwxr-xr-x 8 www-data www-data   4096 Apr 13 10:29 appdata_ocnju38kxfkf
-rw-r--r-- 1 www-data www-data      0 Apr 13 10:26 index.html
-rw-r----- 1 www-data www-data 201149 Apr 13 10:30 nextcloud.log
drwxr-xr-x 3 www-data www-data   4096 Apr 13 10:31 yotam

And my config.php file

root@ubuntu:/media/ubuntu/BIG/nextcloud_data# cat /var/www/nextcloud/config/config.php
<?php
$CONFIG = array (
  'instanceid' => '***',
  'passwordsalt' => '***',
  'secret' => '***',
  'trusted_domains' =>
  array (
    0 => '192.168.1.104',
  ),
  'datadirectory' => '/media/ubuntu/BIG/nextcloud_data',
  'dbtype' => 'mysql',
  'version' => '23.0.3.2',
  'overwrite.cli.url' => 'http://192.168.1.104/nextcloud',
  'dbname' => 'nextclouddb',
  'dbhost' => 'localhost',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'mysql.utf8mb4' => true,
  'dbuser' => '***',
  'dbpassword' => '***',
  'installed' => true,
);

I think on login of the user yotam to the Nextcloud the directory structure is created.
(skeleton files)

Can you login with yotam to your Nextcloud? Please post logs.

Yes. I’ve logged in.

Which logs do you want me to post?

I’ve looked in /media/ubuntu/BIG/nextcloud_data/nextcloud.log file and found this:

"message":"fopen(/media/ubuntu/BIG/nextcloud_data/yotam/files/Templates/Readme.md): Failed to open stream: No such file or directory at /var/www/nextcloud/lib/private/Files/Storage/Local.php#363"

Perhaps because of your problems the needed directorys (e.g. files) are not fully created.

Please create a second user:

sudo -u www-data php /path/to/nextcloud/occ user:add username

Perhaps you must set the password:

sudo -u www-data php /path/to/nextcloud/occ user:resetpassword username

/path/to/nextcloud is the installation path and not the external storage.

Then login with this user.

Read also the occ command documentation .

Hmmm… I think I got part of the error:

$ sudo -u www-data php /var/www/nextcloud/occ user:add yotam2

This version of Nextcloud is not compatible with > PHP 8.0.<br/>You are currently running 8.1.4.

OK, no, I was silly.

I’ve changed the command into

$ sudo -u www-data php8.0 /var/www/nextcloud/occ user:add yotama9

And now everything works.

But, there is still a minor question, the user yotam was supposed to be the admin. How do I make yotama9 the admin? And actually, how do I delete the user yotam?

Please change to PHP 8.0 or PHP 7.4.

Ubuntu 20.04 LTS is not shipped with PHP 8.1.
Why do you not use the standard php version from your repository?
Version is PHP 7.4 and works fine.

https://packages.ubuntu.com/search?keywords=php
System requirements — Nextcloud latest Administration Manual latest documentation
Ok there is 7.4, 8.0 and 8.1 listed. :wink:

Perhaps you can use the old name again.

sudo -u www-data php occ user:delete yotam
sudo -u www-data php occ user:adduser --display-name="USER_NAME" --group="admin" yotam

Thank you!

I use php8.1 because, I’m not sure. The link I’ve posted above suggested installing php8.0, and I follow that. I think that I’ve installed php8.1 and then realized that I should go with 8.0 so I added that.

A minor correction to your second command. It should be:

sudo -u www-data php occ group:adduser admin yotama9

It seems that everything works now (only that I cannot get my heic images to be viewed, but this is a matter for another thread).