Using nc-datadir after a fresh install (no additional user besides ncp) gives the following output:
[ nc-datadir ] (Sat Jun 28 18:33:03 CEST 2025)
Maintenance mode enabled
moving data directory from /var/www/nextcloud/data to /media/data/ncdata/data...
BTRFS filesystem detected
Create subvolume '/media/data/ncdata'
{"reqId":"obhe3d8ivfRDT20pc160","level":2,"time":"2025-06-28T16:33:03+00:00","remoteAddr":"","user":false,"app":"no app in context","method":"","url":"--","message":"Temporary directory /var/www/nextcloud/data/tmp is not present or writable","userAgent":"--","version":"31.0.2.1","data":[]}
{"reqId":"obhe3d8ivfRDT20pc160","level":2,"time":"2025-06-28T16:33:03+00:00","remoteAddr":"","user":false,"app":"no app in context","method":"","url":"--","message":"Temporary directory /var/www/nextcloud/data/tmp is not present or writable","userAgent":"--","version":"31.0.2.1","data":[]}
Nextcloud is in maintenance mode, no apps are loaded.
Commands provided by apps are unavailable.
Your data directory is invalid.
Ensure there is a file called ".ncdata" in the root of the data directory. It should have the content: "# Nextcloud data directory"
**An unhandled exception has been thrown:**
**Exception: Environment not properly prepared. in /var/www/nextcloud/lib/private/Console/Application.php:143**
Stack trace:
#0 /var/www/nextcloud/console.php(81): OC\Console\Application->loadCommands()
#1 /var/www/nextcloud/occ(33): require_once('...')
#2 {main}Nextcloud is in maintenance mode, no apps are loaded.
Commands provided by apps are unavailable.
System config value logfile set to string /media/data/ncdata/data/nextcloud.log
Nextcloud is in maintenance mode, no apps are loaded.
Commands provided by apps are unavailable.
System config value tempdirectory set to string /media/data/ncdata/data/tmp
Installing template 'php/opcache.ini.sh'...
Maintenance mode disabled
Installing template 'ncp-metrics.cfg.sh'...
The NC data directory has been moved successfully.
seams to be just a warning, but how can it be avoided?
By default, the data directory in Nextcloud is .../data!
'datadirectory' => '.../.../nextcloud/data'
So regardless which procedure is used to change or move the data directory , the path to the data directory must include the complete path including.../data because this is where the required .ocdata or .ncdata file is located.
Common error message for incorrect path in config file
Error
Your data directory is invalid.
Ensure there is a file called ".ncdata" in the root of the data directory.
No. But I donβt remember, if I first created a subdirectory .../ncdata or if I just used the mount point of the btrfs volume for the nc-datadir command.
Current (and working) situation:
ncpadmin@ncp:~$ sudo btrfs filesystem show
Label: 'cloud-data' uuid: 2a9bf606-c3bf-467d-a3bf-0b9d4b42ffb9
Total devices 1 FS bytes used 131.38GiB
devid 1 size 426.45GiB used 136.02GiB path /dev/sda3
ncpadmin@ncp:~$ sudo btrfs subvolume list /media/cloud-data
ID 257 gen 1209 top level 5 path ncdata
ID 259 gen 91 top level 5 path ncp-snapshots/daily_2025-07-07_111702
...
and the directory structure is
/media/cloud-data/ncdata/
βββ data
βββ appdata_ocq0gg6p3fof
βββ USER1
βββ USER2
βββ Klaus
βββ ncp-update-backups
βββ .opcache
βββ tmp
For me it looks like the nc-datadir script doesnβt not pre-create the .ncdata file, but creates .opcacheand copies the userdata.