Error: Your data directory is invalid Ensure there is a file called ".ocdata" in the root of the data directory

Support intro

Sorry to hear you’re facing problems :slightly_frowning_face:

help.nextcloud.com is for home/non-enterprise users. If you’re running a business, paid support can be accessed via portal.nextcloud.com where we can ensure your business keeps running smoothly.

In order to help you as quickly as possible, before clicking Create Topic please provide as much of the below as you can. Feel free to use a pastebin service for logs, otherwise either indent short log examples with four spaces:

example

Or for longer, use three backticks above and below the code snippet:

longer
example
here

Some or all of the below information will be requested if it isn’t supplied; for fastest response please provide as much as you can :heart:

Nextcloud version (eg, 20.0.5): 23.0.5
Operating system and version (eg, Ubuntu 20.04): Debian 11
Apache or nginx version (eg, Apache 2.4.25): Apache/2.4.53 (Debian)
PHP version (eg, 7.4): 7.4

The issue you are facing:

I get the following errors on my settings page

There are some errors regarding your setup.

  • It was not possible to execute the cron job via CLI. The following technical errors have appeared:
  1. Your data directory is invalid Ensure there is a file called “.ocdata” in the root of the data directory.
  2. Cannot create “data” directory This can usually be fixed by giving the webserver write access to the root directory. See https://docs.nextcloud.com/server/23/go.php?to=admin-dir_permissions

Is this the first time you’ve seen this error? (Y/N): N

Steps to replicate it:

  1. Install Nextdcloud with data directory on /media/nc-500gb/
  2. Turn off server; disconnect data drive, add, migrate, and reorganize data on /media/nc-2tb/
  3. Chown, chmod, update config.php, update oc_storages in databases, occ files:scan
  4. Visit settings page; see error.

The output of your Nextcloud log in Admin > Logging:

See: Mozilla Community Pastebin/GBN2sWJf (IRC logs)

The output of your config.php file in /path/to/nextcloud (make sure you remove any identifiable information!):

<?php
$CONFIG = array (
  'instanceid' => 'xxxx',
  'passwordsalt' => 'xxxx',
  'secret' => 'xxxx',
  'trusted_domains' => 
  array (
    0 => 'localhost',
    1 => 'nc.xxxx.com',
    2 => '192.168.xxx.xxx',
  ),
  'datadirectory' => '/media/nc-2tb/ncdata',
  'dbtype' => 'mysql',
  'version' => '23.0.5.1',
  'overwrite.cli.url' => 'http://nc.xxxx.com',
  'dbname' => 'nextcloud',
  'dbhost' => 'localhost',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'mysql.utf8mb4' => true,
  'dbuser' => 'nextcloud',
  'dbpassword' => 'xxxx',
  'installed' => true,
  'updater.secret' => 'xxxx',
  'maintenance' => false,
  'theme' => '',
  'loglevel' => 2,
);

The output of your Apache/nginx/system log in /var/log/____:

[Mon May 30 12:30:52.911782 2022] [php7:notice] [pid 737] [client 192.168.xxx.xxx:48688] {"reqId":"zxT0jZYcUjD5Ne2Tbc7X","level":3,"time":"2022-05-30T16:30:52+00:00","remoteAddr":"192.168.xxx.xxx","user":"--","app":"PHP","method":"GET","url":"/index.php/204","message":"file_get_contents(/media/nc-500gb/ncdata/appdata_ocpk7we61bcu/js/core/merged-template-prepend.js.deps): failed to open stream: No such file or directory at /var/www/nc.xxxx.com/lib/private/Files/Storage/Local.php#277","userAgent":"Mozilla/5.0 (Android) Nextcloud-android/3.20.1","version":"23.0.4.1","exception":{"Exception":"Error","Message":"file_get_contents(/media/nc-500gb/ncdata/appdata_ocpk7we61bcu/js/core/merged-template-prepend.js.deps): failed to open stream: No such file or directory at /var/www/nc.xxxx.com/lib/private/Files/Storage/Local.php#277","Code":0,"Trace":[{"function":"onError","class":"OC\\\\Log\\\\ErrorHandler","type":"::"},{"file":"/var/www/nc.xxxx.com/lib/private/Files/Storage/Local.php","line":277,"function":"file_get_contents"},{"file":"/var/www/nc.xxxx.com/lib/private/Files/Storage/Wrapper/Wrapper.php","line":247,"function":"file_get_contents","class":"OC\\\\Files\\\\Storage\\\\Local","type":"->"},{"file":"/var/www/nc.xxxx.com/lib/private/Files/View.php","line":1171,"function":"file_get_contents","class":"OC\\\\Files\\\\Storage\\\\Wrapper\\\\Wrapper","type":"->"},{"file":"/var/www/nc.xxxx.com/lib/private/Files/View.php","line":601,"function":"basicOperation","class":"OC\\\\Files\\\\View","type":"->"},{"file":"/var/www/nc.xxxx.com/lib/private/Files/Node/File.php","line":56,"function":"file_get_contents","class":"OC\\\\Files\\\\View","type":"->"},{"file":"/var/www/nc.xxxx.com/lib/private/Files/SimpleFS/SimpleFile.php","line":90,"function":"getContent","class":"OC\\\\Files\\\\Node\\\\File","type":"->"},{"file":"/var/www/nc.xxxx.com/lib/private/Template/JSCombiner.php","line":127,"function":"getContent","class":"OC\\\\Files\\\\SimpleFS\\\\SimpleFile","type":"->"},{"file":"/var/www/nc.xxxx.com/lib/private/Template/JSCombiner.php","line":102,"function":"isCached","class":"OC\\\\Template\\\\JSCombiner","type":"->"},{"file":"/var/www/nc.xxxx.com/lib/private/Template/JSResourceLocator.php","line":115,"function":"process","class":"OC\\\\Template\\\\JSCombiner","type":"->"},{"file":"/var/www/nc.xxxx.com/lib/private/Template/JSResourceLocator.php","line":71,"function":"cacheAndAppendCombineJsonIfExist","class":"OC\\\\Template\\\\JSResourceLocator","type":"->"},{"file":"/var/www/nc.xxxx.com/lib/private/Template/ResourceLocator.php","line":78,"function":"doFind","class":"OC\\\\Template\\\\JSResourceLocator","type":"->"},{"file":"/var/www/nc.xxxx.com/lib/private/TemplateLayout.php","line":388,"function":"find","class":"OC\\\\Template\\\\ResourceLocator","type":"->"},{"file":"/var/www/nc.xxxx.com/lib/private/TemplateLayout.php","line":216,"function":"findJavascriptFiles","class":"OC\\\\TemplateLayout","type":"::"},{"file":"/var/www/nc.xxxx.com/lib/private/legacy/OC_Template.php","line":182,"function":"__construct","class":"OC\\\\TemplateLayout","type":"->"},{"file":"/var/www/nc.xxxx.com/lib/private/Template/Base.php","line":132,"function":"fetchPage","class":"OC_Template","type":"->"},{"file":"/var/www/nc.xxxx.com/lib/private/legacy/OC_Template.php","line":272,"function":"printPage","class":"OC\\\\Template\\\\Base","type":"->"},{"file":"/var/www/nc.xxxx.com/lib/base.php","line":662,"function":"printGuestPage","class":"OC_Template","type":"::"},{"file":"/var/www/nc.xxxx.com/lib/base.php","line":1089,"function":"init","class":"OC","type":"::"},{"file":"/var/www/nc.xxxx.com/index.php","line":34,"args":["/var/www/nc.xxxx.com/lib/base.php"],"function":"require_once"}],"File":"/var/www/nc.xxxx.com/lib/private/Log/ErrorHandler.php","Line":92,"CustomMessage":"--"}}
[Mon May 30 12:30:53.679980 2022] [php7:notice] [pid 737] [client 192.168.xxx.xxx:48688] {"reqId":"zxT0jZYcUjD5Ne2Tbc7X","level":3,"time":"2022-05-30T16:30:53+00:00","remoteAddr":"192.168.xxx.xxx","user":"--","app":"PHP","method":"GET","url":"/index.php/204","message":"file_put_contents(/media/nc-500gb/ncdata/appdata_ocpk7we61bcu/js/core/merged-template-prepend.js): failed to open stream: No such file or directory at /var/www/nc.xxxx.com/lib/private/Files/Storage/Local.php#282","userAgent":"Mozilla/5.0 (Android) Nextcloud-android/3.20.1","version":"23.0.4.1","exception":{"Exception":"Error","Message":"file_put_contents(/media/nc-500gb/ncdata/appdata_ocpk7we61bcu/js/core/merged-template-prepend.js): failed to open stream: No such file or directory at /var/www/nc.xxxx.com/lib/private/Files/Storage/Local.php#282","Code":0,"Trace":[{"function":"onError","class":"OC\\\\Log\\\\ErrorHandler","type":"::"},{"file":"/var/www/nc.xxxx.com/lib/private/Files/Storage/Local.php","line":282,"function":"file_put_contents"},{"file":"/var/www/nc.xxxx.com/lib/private/Files/Storage/Wrapper/Wrapper.php","line":258,"function":"file_put_contents","class":"OC\\\\Files\\\\Storage\\\\Local","type":"->"},{"file":"/var/www/nc.xxxx.com/lib/private/Files/View.php","line":1169,"function":"file_put_contents","class":"OC\\\\Files\\\\Storage\\\\Wrapper\\\\Wrapper","type":"->"},{"file":"/var/www/nc.xxxx.com/lib/private/Files/View.php","line":706,"function":"basicOperation","class":"OC\\\\Files\\\\View","type":"->"},{"file":"/var/www/nc.xxxx.com/lib/private/Files/Node/Folder.php","line":198,"function":"file_put_contents","class":"OC\\\\Files\\\\View","type":"->"},{"file":"/var/www/nc.xxxx.com/lib/private/Files/SimpleFS/NewSimpleFile.php","line":133,"function":"newFile","class":"OC\\\\Files\\\\Node\\\\Folder","type":"->"},{"file":"/var/www/nc.xxxx.com/lib/private/Template/JSCombiner.php","line":202,"function":"putContent","class":"OC\\\\Files\\\\SimpleFS\\\\NewSimpleFile","type":"->"},{"file":"/var/www/nc.xxxx.com/lib/private/Template/JSCombiner.php","line":105,"function":"cache","class":"OC\\\\Template\\\\JSCombiner","type":"->"},{"file":"/var/www/nc.xxxx.com/lib/private/Template/JSResourceLocator.php","line":115,"function":"process","class":"OC\\\\Template\\\\JSCombiner","type":"->"},{"file":"/var/www/nc.xxxx.com/lib/private/Template/JSResourceLocator.php","line":71,"function":"cacheAndAppendCombineJsonIfExist","class":"OC\\\\Template\\\\JSResourceLocator","type":"->"},{"file":"/var/www/nc.xxxx.com/lib/private/Template/ResourceLocator.php","line":78,"function":"doFind","class":"OC\\\\Template\\\\JSResourceLocator","type":"->"},{"file":"/var/www/nc.xxxx.com/lib/private/TemplateLayout.php","line":388,"function":"find","class":"OC\\\\Template\\\\ResourceLocator","type":"->"},{"file":"/var/www/nc.xxxx.com/lib/private/TemplateLayout.php","line":216,"function":"findJavascriptFiles","class":"OC\\\\TemplateLayout","type":"::"},{"file":"/var/www/nc.xxxx.com/lib/private/legacy/OC_Template.php","line":182,"function":"__construct","class":"OC\\\\TemplateLayout","type":"->"},{"file":"/var/www/nc.xxxx.com/lib/private/Template/Base.php","line":132,"function":"fetchPage","class":"OC_Template","type":"->"},{"file":"/var/www/nc.xxxx.com/lib/private/legacy/OC_Template.php","line":272,"function":"printPage","class":"OC\\\\Template\\\\Base","type":"->"},{"file":"/var/www/nc.xxxx.com/lib/base.php","line":662,"function":"printGuestPage","class":"OC_Template","type":"::"},{"file":"/var/www/nc.xxxx.com/lib/base.php","line":1089,"function":"init","class":"OC","type":"::"},{"file":"/var/www/nc.xxxx.com/index.php","line":34,"args":["/var/www/nc.xxxx.com/lib/base.php"],"function":"require_once"}],"File":"/var/www/nc.xxxx.com/lib/private/Log/ErrorHandler.php","Line":92,"CustomMessage":"--"}}
[Mon May 30 12:30:53.682574 2022] [php7:notice] [pid 737] [client 192.168.xxx.xxx:48688] {"reqId":"zxT0jZYcUjD5Ne2Tbc7X","level":3,"time":"2022-05-30T16:30:53+00:00","remoteAddr":"192.168.xxx.xxx","user":"--","app":"no app in context","method":"GET","url":"/index.php/204","message":"JSCombiner: unable to cache: merged-template-prepend.js","userAgent":"Mozilla/5.0 (Android) Nextcloud-android/3.20.1","version":"23.0.4.1"}
[Mon May 30 12:30:53.913940 2022] [php7:notice] [pid 737] [client 192.168.xxx.xxx:48688] {"reqId":"zxT0jZYcUjD5Ne2Tbc7X","level":3,"time":"2022-05-30T16:30:53+00:00","remoteAddr":"192.168.xxx.xxx","user":"--","app":"PHP","method":"GET","url":"/index.php/204","message":"fopen(/media/nc-500gb/ncdata/nextcloud.log): failed to open stream: No such file or directory at /var/www/nc.xxxx.com/lib/private/Log/File.php#84","userAgent":"Mozilla/5.0 (Android) Nextcloud-android/3.20.1","version":"23.0.4.1"}

Output of relevant commands:

$ sudo grep datadirectory /var/www/nc.hxfam.com/config/config.php
  'datadirectory' => '/media/nc-2tb/ncdata',
$ sudo ls -ld $( sudo grep datadirectory /var/www/nc.hxfam.com/config/config.php | awk '{ print $3 }' | grep -oP "[^']*[^']" | head -1 )
drwxr-x--- 5 www-data www-data 4096 May  4 19:05 /media/nc-2tb/ncdata
$ ls -l /media/ 
total 8
drwxr-xr-x 4 www-data www-data 4096 May  4 19:05 nc-2tb
drwxr-xr-x 2 root     root     4096 Apr 22 08:49 nc-500gb
$ sudo systemctl status nc-automount-links
Unit nc-automount-links.service could not be found.

Do I need to create some kind of symlink from /media/nc-500gb/ to /media/nc-2tb/?
What would you all recommend?

Thanks
–P