OCP Files NotFoundException after setting datadir

Steps to reproduce

  1. Installed ownCloud 10.7 on Raspberry Pi 4 with Raspbian
  2. Tried first connection to dashboard, logged smoothly
  3. Followed instructions to move datadir to a different path, specifically on an external USB drive
  4. Checked that USB drive path was set properly for www-data user from terminal before and after applying the datadir change guide

Expected behaviour

Logging in and seeing datadir changed to external drive

Actual behaviour

After restarting Apache and occ the dashboard web page returns an Internal server error message

Server configuration

Operating system: Raspbian 10

Web server: Apache

Database: MySQL

PHP version: cat /etc/os-release

ownCloud version: (see ownCloud admin page) ownCloud 10.7

Updated from an older ownCloud or fresh install: fresh install

Where did you install ownCloud from: tar

Signing status (ownCloud 9.0 and above): not enabled

Login as admin user into your ownCloud and access 
http://example.com/index.php/settings/integrity/failed 
paste the results into https://gist.github.com/ and puth the link here.

The content of config/config.php:

{
    "system": {
        "passwordsalt": "***REMOVED SENSITIVE VALUE***",
        "secret": "***REMOVED SENSITIVE VALUE***",
        "trusted_domains": [
            "localhost",
            "192.168.1.113"
        ],
        "datadirectory": "\/media\/wde\/data\/",
        "overwrite.cli.url": "http:\/\/localhost",
        "dbtype": "mysql",
        "version": "10.7.0.4",
        "dbname": "owncloud",
        "dbhost": "localhost",
        "dbtableprefix": "oc_",
        "mysql.utf8mb4": true,
        "dbuser": "***REMOVED SENSITIVE VALUE***",
        "dbpassword": "***REMOVED SENSITIVE VALUE***",
        "logtimezone": "UTC",
        "apps_paths": [
            {
                "path": "\/var\/www\/owncloud\/apps",
                "url": "\/apps",
                "writable": false
            },
            {
                "path": "\/var\/www\/owncloud\/apps-external",
                "url": "\/apps-external",
                "writable": true
            }
        ],
        "installed": true,
        "instanceid": "occg2z94ljfn",
        "memcache.local": "\\OC\\Memcache\\APCu",
        "memcache.locking": "\\OC\\Memcache\\Redis",
        "redis": {
            "host": "127.0.0.1",
            "port": "6379"
        },
        "maintenance": false
    }
}

List of activated apps:

Enabled:
  - comments:
    - Version: 0.3.0
    - Path: /var/www/owncloud/apps/comments
  - configreport:
    - Version: 0.2.0
    - Path: /var/www/owncloud/apps/configreport
  - dav:
    - Version: 0.6.0
    - Path: /var/www/owncloud/apps/dav
  - federatedfilesharing:
    - Version: 0.5.0
    - Path: /var/www/owncloud/apps/federatedfilesharing
  - federation:
    - Version: 0.1.0
    - Path: /var/www/owncloud/apps/federation
  - files:
    - Version: 1.5.2
    - Path: /var/www/owncloud/apps/files
  - files_external:
    - Version: 0.7.1
    - Path: /var/www/owncloud/apps/files_external
  - files_mediaviewer:
    - Version: 1.0.4
    - Path: /var/www/owncloud/apps/files_mediaviewer
  - files_sharing:
    - Version: 0.14.0
    - Path: /var/www/owncloud/apps/files_sharing
  - files_trashbin:
    - Version: 0.9.1
    - Path: /var/www/owncloud/apps/files_trashbin
  - files_versions:
    - Version: 1.3.0
    - Path: /var/www/owncloud/apps/files_versions
  - firstrunwizard:
    - Version: 1.2.0
    - Path: /var/www/owncloud/apps/firstrunwizard
  - market:
    - Version: 0.6.0
    - Path: /var/www/owncloud/apps/market
  - notifications:
    - Version: 0.5.2
    - Path: /var/www/owncloud/apps/notifications
  - provisioning_api:
    - Version: 0.5.0
    - Path: /var/www/owncloud/apps/provisioning_api
  - systemtags:
    - Version: 0.3.0
    - Path: /var/www/owncloud/apps/systemtags
  - updatenotification:
    - Version: 0.2.1
    - Path: /var/www/owncloud/apps/updatenotification
Disabled:
  - encryption:
    - Path: /var/www/owncloud/apps/encryption
  - external:
    - Path: /var/www/owncloud/apps/external
  - user_external:
    - Path: /var/www/owncloud/apps/user_external

Are you using external storage, if yes which one: /media/wde

Are you using encryption: no

Are you using an external user-backend, if yes which one: no

Client configuration

Browser: stock Raspbian browser

Operating system:

Logs

Web server error log

ownCloud log (data/owncloud.log)

{"reqId":"l4pyHdS7KY4g4VIucPXI","level":3,"time":"2021-04-02T20:36:41+00:00","remoteAddr":"192.168.1.113","user":"magione","app":"index","method":"GET","url":"-index.php-apps-gfiles-/?dir=-/&fileid=3","message":"Exception: {-"Exception-":-"OCP -Files -NotFoundException-",-"Message-":-"-",-"Code-":0,-"Trace-":-"#0  /var /www /owncloud /apps /files /lib /Controller /ViewController.php(134): OC_Helper::getStorageInfo(' /', false)--n#1  /var /www /owncloud /apps /files /lib /Controller /ViewController.php(208): OCA -Files -Controller -ViewController->getStorageInfo()--n#2  /var /www /owncloud /lib /private /AppFramework /Http /Dispatcher.php(153): OCA -Files -Controller -ViewController->index(' /', '', '3', NULL)--n#3  /var /www /owncloud /lib /private /AppFramework /Http /Dispatcher.php(85): OC -AppFramework -Http -Dispatcher->executeController(Object(OCA -Files -Controller -ViewController), 'index')--n#4  /var /www /owncloud /lib /private /AppFramework /App.php(100): OC -AppFramework -Http -Dispatcher->dispatch(Object(OCA -Files -Controller -ViewController), 'index')--n#5  /var /www /owncloud /lib /private /AppFramework /Routing /RouteActionHandler.php(47): OC -AppFramework -App::main('ViewController', 'index', Object(OC -AppFramework -DependencyInjection -DIContainer), Array)--n#6  /var /www /owncloud /lib /private /Route /Router.php(341): OC -AppFramework -Routing -RouteActionHandler->__invoke(Array)--n#7  /var /www /owncloud /lib /base.php(915): OC -Route -Router->match(' /apps /files /')--n#8  /var /www /owncloud /index.php(54): OC::handleRequest()--n#9 {main}-",-"File-":-" /var /www /owncloud /lib /private /legacy /helper.php-",-"Line-":585}"}
{"reqId":"tfRZ9XIYtLQXYfpHpmhh","level":3,"time":"2021-04-02T20:36:41+00:00","remoteAddr":"192.168.1.113","user":"magione","app":"index","method":"GET","url":"-index.php-apps-gfiles-/?dir=-/&fileid=3","message":"Exception: {-"Exception-":-"OCP -Files -NotFoundException-",-"Message-":-"-",-"Code-":0,-"Trace-":-"#0  /var /www /owncloud /apps /files /lib /Controller /ViewController.php(134): OC_Helper::getStorageInfo(' /', false)--n#1  /var /www /owncloud /apps /files /lib /Controller /ViewController.php(208): OCA -Files -Controller -ViewController->getStorageInfo()--n#2  /var /www /owncloud /lib /private /AppFramework /Http /Dispatcher.php(153): OCA -Files -Controller -ViewController->index(' /', '', '3', NULL)--n#3  /var /www /owncloud /lib /private /AppFramework /Http /Dispatcher.php(85): OC -AppFramework -Http -Dispatcher->executeController(Object(OCA -Files -Controller -ViewController), 'index')--n#4  /var /www /owncloud /lib /private /AppFramework /App.php(100): OC -AppFramework -Http -Dispatcher->dispatch(Object(OCA -Files -Controller -ViewController), 'index')--n#5  /var /www /owncloud /lib /private /AppFramework /Routing /RouteActionHandler.php(47): OC -AppFramework -App::main('ViewController', 'index', Object(OC -AppFramework -DependencyInjection -DIContainer), Array)--n#6  /var /www /owncloud /lib /private /Route /Router.php(341): OC -AppFramework -Routing -RouteActionHandler->__invoke(Array)--n#7  /var /www /owncloud /lib /base.php(915): OC -Route -Router->match(' /apps /files /')--n#8  /var /www /owncloud /index.php(54): OC::handleRequest()--n#9 {main}-",-"File-":-" /var /www /owncloud /lib /private /legacy /helper.php-",-"Line-":585}"}
{"reqId":"a35F8M8naNN9vfAK56Yr","level":3,"time":"2021-04-02T20:36:43+00:00","remoteAddr":"192.168.1.113","user":"magione","app":"index","method":"GET","url":"-index.php-apps-gfiles-/","message":"Exception: {-"Exception-":-"OCP -Files -NotFoundException-",-"Message-":-"-",-"Code-":0,-"Trace-":-"#0  /var /www /owncloud /apps /files /lib /Controller /ViewController.php(134): OC_Helper::getStorageInfo(' /', false)--n#1  /var /www /owncloud /apps /files /lib /Controller /ViewController.php(208): OCA -Files -Controller -ViewController->getStorageInfo()--n#2  /var /www /owncloud /lib /private /AppFramework /Http /Dispatcher.php(153): OCA -Files -Controller -ViewController->index('', '', NULL, NULL)--n#3  /var /www /owncloud /lib /private /AppFramework /Http /Dispatcher.php(85): OC -AppFramework -Http -Dispatcher->executeController(Object(OCA -Files -Controller -ViewController), 'index')--n#4  /var /www /owncloud /lib /private /AppFramework /App.php(100): OC -AppFramework -Http -Dispatcher->dispatch(Object(OCA -Files -Controller -ViewController), 'index')--n#5  /var /www /owncloud /lib /private /AppFramework /Routing /RouteActionHandler.php(47): OC -AppFramework -App::main('ViewController', 'index', Object(OC -AppFramework -DependencyInjection -DIContainer), Array)--n#6  /var /www /owncloud /lib /private /Route /Router.php(341): OC -AppFramework -Routing -RouteActionHandler->__invoke(Array)--n#7  /var /www /owncloud /lib /base.php(915): OC -Route -Router->match(' /apps /files /')--n#8  /var /www /owncloud /index.php(54): OC::handleRequest()--n#9 {main}-",-"File-":-" /var /www /owncloud /lib /private /legacy /helper.php-",-"Line-":585}"}
{"reqId":"wXrulWD9jHU4e0SEiTD1","level":3,"time":"2021-04-02T20:41:43+00:00","remoteAddr":"192.168.1.113","user":"magione","app":"no app in context","method":"GET","url":"-ocs-v2.php-gapps-/notifications-/api-/v1-/notifications?format=json","message":"User backend OC--User--Database is returning home: -/media-/wde-/data-/-/magione for user: magione which differs from existing value: -/media-/wde-/data-/magione-/files"}

Browser log

ownCloud
Internal Server Error
The server encountered an internal error and was unable to complete your request.

Please contact the server administrator if this error reappears multiple times and include the technical details below in your report.

More details can be found in the server log.

Technical details
Remote Address: 192.168.1.113
Request ID: a35F8M8naNN9vfAK56Yr

Hey,

this sounds to me that the following documentation provided by the ownCloud people wasn’t followed correctly (i think the SQL update could be wrong here):

https://doc.owncloud.com/server/admin_manual/maintenance/manually-moving-data-folders.html

Hi Tom, thank you for your reply.
I do have followed the steps provided by the documentation, this is the output from the database:
MariaDB [owncloud]> select * from oc_storages;

+-------------------------+------------+-----------+--------------+
| id | numeric_id | available | last_checked |
+-------------------------+------------+-----------+--------------+
| local::/media/wde/data/ | 2 | 1 | NULL |
| home::magione | 4 | 1 | NULL |
+-------------------------+------------+-----------+--------------+

The path for local is the same as the config.php file.

Also for the oc_accounts table:

MariaDB [owncloud]> select * from oc_accounts;
+----+-------+---------+---------------+--------------+-------+------------+------------------+-------------------------------+-------+
| id | email | user_id | lower_user_id | display_name | quota | last_login | backend | home | state |
+----+-------+---------+---------------+--------------+-------+------------+------------------+-------------------------------+-------+
| 1 | NULL | magione | magione | magione | NULL | 1617478603 | OC\User\Database | /media/wde/data/magione/files | 1 |
+----+-------+---------+---------------+--------------+-------+------------+------------------+-------------------------------+-------+

In oc_accounts, remove the trailing ‘/files’.

/media/wde/data/magione’ should be correct.

Hi alfredb, thank you for your reply, I changed the home entry as suggested:

| 1 | NULL | magione | magione | magione | NULL | 1617614874 | OC\User\Database | /media/wde/data/magione | 1 |

The “Internal server error message” is gone, but I’m left instead with this message:

You don't have permissions to access this file/folder - Please contact the owner to share it with you.

The user www-data has access to the folder, though:

sudo -u www-data ls -la /media/wde/data/data/magione/
drwxr-xr-x 4 www-data www-data 4096 Apr 2 17:52 .
drwxrwx--- 6 www-data www-data 4096 Apr 3 00:10 ..
drwxr-xr-x 2 www-data www-data 4096 Apr 2 17:52 cache
drwxr-xr-x 5 www-data www-data 4096 Apr 3 21:36 files

Any idea about what could be the source of the message?

Well, I assume this is the old story: the volume must be mounted for user www-data.

The volume is already mounted for www-data user and group:
ls -l /media/wde
drwxrwx--- 6 www-data www-data 4096 Apr 3 00:10 data

Hey,

i think that these are the unix permissions but the mount point itself could have different mount permissions (i think you can check that with the mount command).

If i’m remember correctly you also need to make sure that the external USB drive is e.g. formatted with a linux file system like ext4 (Windows filesystems like NTFS aren’t supported as some one from ownCloud has stated some time ago).

1 Like

:roll_eyes: Believe it or not, the mount command needs

uid=$(id -u www-data),gid=$(id -g www-data)

At least according my experience…

1 Like

Hey,

i think this is really strange because the documentation about the oc_accounts table provided by the ownCloud people mentions that the entry should include the /files:

this column contains the absolute path for user folders, e.g., /mnt/owncloud/data/my_user/files .

Maybe some one with a github account could let the ownCloud people at https://github.com/owncloud/docs/issues to know that the example might be wrong?

I only checked my installation, but not the docs.

Maybe they’ll fix it, but probably rather not. There are tons of such glitches in the docs. Unfortunately is , thanks the OCIS hype, the motivation rather low, also on my side, even if I still have a GH account.

The mount command return an error with the option for uid and gid, so I have to rule this out.

Sorry, but I’m not entirely sure of what you mean with this, and from the man page of mount I was unable to retrieve anything about it,

The USB disk is formatted in ext4, trying with NTFS was even worse.

That looked strange for me too, but I guess it was worth trying also that way just to be sure.

OK, my bad, maybe I mixed up something… sorry. The uid/gid= doesn’t work for ext4.

Did you try the hint and the end of the linked article I gave to you?

…to change the owner of an ext4 mount simply run

chown username /mountpoint

after it has been mounted

So, I didn’t exactly understand how and at which point but seems like I was able to solve the issue.
Thank you everyone for the help!