What the message looks like
Your data directory is invalid
Ensure there is a file called ".ocdata" in the root of the data directory.Common causes
- The data volume (second disk, NFS, SMB, bind mount) is not mounted after a reboot, so the path exists but is empty.
datadirectoryinconfig.phppoints to a different path than the real one, for example after a move or a migration.- The hidden file
.ocdatawas not copied, because the copy skipped dot files or only some folders were restored from a backup. - The web server user cannot read the directory, for example after wrong
chownor a changed mount option.
Check
- Which path does Nextcloud use?
grep datadirectory /var/www/nextcloud/config/config.php - Is the marker file there?
ls -la /srv/nextcloud-data/.ocdata - Is the volume really mounted?
findmnt /srv/nextcloud-data - Owner and mode of the directory
stat -c '%U:%G %a %n' /srv/nextcloud-data
Fix
- Mount the volume first and check that your user folders and
nextcloud.logare visible in the data directory. Make the mount start before the web server, for example withRequiresMountsFor=/srv/nextcloud-datain a systemd drop-in. - If the path in
config.phpis wrong, set the real one indatadirectoryand nowhere else. - Only when the folder is the real data directory and the file is missing, recreate it:
sudo -u www-data touch /srv/nextcloud-data/.ocdata. Never do this on an empty mount point. - Fix the owner:
chown -R www-data:www-data /srv/nextcloud-dataand mode0750on the directory. - Reload the page. For future copies use
rsync -a, which keeps dot files.
FAQ
Can I just create .ocdata to make the error go away?
Only if you are sure the directory holds your real data. On an unmounted empty folder it would make Nextcloud start with a new, empty instance, and the first uploads would land on the wrong disk.
Why does it happen after every reboot?
Usually the mount comes up later than the web server or fails silently. Check the mount unit or the fstab line and add a dependency so the web server waits for it.