NextcloudPi : Setup external storage issue

Hello everyone,

I have some issue for setting up my external storage. I tried throught the NextcloudPi Wizard, but I get this error after clicking on the “Move data to USB” :

[ nc-automount ] (Sun Sep 25 18:58:17 BST 2022)
automount enabled

[ nc-datadir ] (Sun Sep 25 18:58:24 BST 2022)
Nextcloud is in maintenance mode, hence the database isn’t accessible.
Cannot perform any command except ‘maintenance:mode --off’

INFO: /media/myCloudDrive/ncdata is not empty. Creating backup /media/myCloudDrive/ncdata-09-25-22.1664128704
{“reqId”:“dVvhOV4HNqWp415WHgHc”,“level”:2,“time”:“2022-09-25T17:58:25+00:00”,“remoteAddr”:“”,“user”:“–”,“app”:“no app in context”,“method”:“”,“url”:“–”,“message”:“Temporary directory /media/myCloudDrive/ncdata/data/tmp is not present or writable”,“userAgent”:“–”,“version”:“24.0.3.2”,“data”:}
{“reqId”:“lsx0mu22hHHjXhK3Ooca”,“level”:2,“time”:“2022-09-25T17:58:26+00:00”,“remoteAddr”:“”,“user”:“–”,“app”:“no app in context”,“method”:“”,“url”:“–”,“message”:“Temporary directory /media/myCloudDrive/ncdata/data/tmp is not present or writable”,“userAgent”:“–”,“version”:“24.0.3.2”,“data”:}
Your data directory is invalid.
Ensure there is a file called “.ocdata” in the root of the data directory.

Cannot create “data” directory.
This can usually be fixed by giving the web server write access to the root directory. See https://docs.nextcloud.com/server/24/go.php?to=admin-dir_permissions

An unhandled exception has been thrown:
Exception: Environment not properly prepared. in /var/www/nextcloud/lib/private/Console/Application.php:164
Stack trace:
#0 /var/www/nextcloud/console.php(99): OC\Console\Application->loadCommands()
#1 /var/www/nextcloud/occ(11): require_once(‘/var/www/nextcl…’)
#2 {main}

Everything worked find during the installation until here.

I’m a bit lost ? someone can help me ?

Best regards,

It doesn’t have permissions to write on your external drive.

sudo chown -R www-data:www-data /media/myCloudDrive

Should fix it, unless you’re using the wrong filesystem/partitioning on the drive which doesn’t support Linux permissions system

If you’re using a Raspberry Pi 4, you can boot directly from the external drive instead, saving you the hassle of dealing with the permissions. Just need to change the boot order in raspi-config and install directly on the external drive instead

Hello, thanks for answering so quickly !

Thanks for your answer. I finally fixed my issue changing direct config.php, I replaced /var/www/nextcloud/data for /media/myCloudDrive/ncdata/data. Same in php.ini.

It did work, BUT I now can’t, throught NextcloudPi wizard setup fail2ban. I got this message :

[ fail2ban ] (Sun Sep 25 22:46:31 BST 2022)
directory Your data directory is not writable.
Permissions can usually be fixed by giving the web server write access to the root directory. See https://docs.nextcloud.com/server/24/go.php?to=admin-dir_permissions.

An unhandled exception has been thrown:
Exception: Environment not properly prepared. in /var/www/nextcloud/lib/private/Console/Application.php:164
Stack trace:
#0 /var/www/nextcloud/console.php(99): OC\Console\Application->loadCommands()
#1 /var/www/nextcloud/occ(11): require_once('/var/www not found

System config value trusted_domains => 3 set to string nextcloudpi
[ fail2ban ] (Sun Sep 25 22:47:26 BST 2022)
System config value overwrite.cli.url set to string https://nextcloudpi/
directory /var/www/nextcloud/data not found

System config value trusted_proxies => 11 set to string 127.0.0.1
System config value trusted_proxies => 12 set to string ::1
System config value trusted_proxies => 13 set to string nextcloudpi
System config value trusted_proxies => 14 set to string 192.168.1.19
✓ redis is configured
✓ push server is receiving redis messages
✓ push server can load mount info from database
✓ push server can connect to the Nextcloud server
✓ push server is a trusted proxy
✓ push server is running the same version as the app
configuration saved
[ fail2ban ] (Sun Sep 25 22:47:55 BST 2022)
directory /var/www/nextcloud/data not found

I tried your command, but like this :
sudo chown -R www-data:www-data /var/www/nextcloud

And fail2ban was able to write !

Hope I didn’t make anything wrong ! :smiley:

1 Like

No, you did the right thing :+1:

Since you changed your data directory, to change the command was the right choice

1 Like