Can't see files/directories or write to external drive

Can’t see files/directories or write to external drive, this is a new install on a Rasbrerry Pi 4 for use on a private local area network. I can see the drive as a directory in the folder list under the Files tab, but when I open the directory I can’t see the existing content of the drive, not can I add or created files or directories.

Nextcloud version 21.0.1
Operating system and version Ubuntu MATE for Raspberry Pi 20.04 (ARMv8 64-bit)
Apache/2.4.41
PHP Version 7.4.3

The external drive is a USB hard drive which is mounted by Unbutu and apears in the Nextcloud file list. The Admin External storage shows it with a green tick. On the Personnal External storage sometimes get a red ! which turns to green tick when clicked.

Possilbly relavent errors:

Error no app in context OCP\Files\NotPermittedException: Could not create path

Error PHP Error: chmod(): Permission denied at /var/www/html/nextcloud/lib/private/Files/Storage/Local.php#91

My initial thoughts were that this was a permissions error, so set the permissions to the eternal drive to 770, which hasn’t changed anything.

Any ideas?

Hi, could you please post some more infos about your system like how did you install Nextcloud (based on a tutorial, docker, script, snap) the content of your config.php file and the complete error message?

It was a manual install based on several tutorials
https://medium.com/@loneauios/how-to-install-nextcloud-on-your-raspberry-pi-4-c20dfcbc45a7

config:

<?php $CONFIG = array ( 'instanceid' => '********', 'passwordsalt' => '**********', 'secret' => '************', 'trusted_domains' => array ( 0 => '192.****.***.***', ), 'datadirectory' => '/var/www/html/nextcloud/data', 'dbtype' => 'mysql', 'version' => '21.0.1.1', 'overwrite.cli.url' => 'http://192.****.***.***/nextcloud', 'dbname' => 'nextcloud', 'dbhost' => 'localhost', 'dbport' => '', 'dbtableprefix' => 'oc_', 'mysql.utf8mb4' => true, 'dbuser' => 'nextclouduser', 'dbpassword' => '*********', 'installed' => true, 'mail_smtpmode' => 'smtp', 'mail_smtphost' => '********.uk', 'mail_sendmailmode' => 'smtp', 'mail_smtpport' => '465 46593', 'mail_from_address' => '*****', 'mail_smtpauthtype' => 'LOGIN', 'mail_smtpsecure' => 'ssl', 'mail_domain' => '********.net', 'mail_smtpauth' => 1, 'mail_smtpname' => '*******', 'mail_smtppassword' => '******', 'memcache.distributed' => '\OC\Memcache\Redis', 'memcache.local' => '\OC\Memcache\Redis', 'memcache.locking' => '\OC\Memcache\Redis', 'redis' => array( 'host' => 'localhost', 'port' => 6379, ), );

|Error|no app in context|OCP\Files\NotPermittedException: Could not create path

  1. /var/www/html/nextcloud/lib/private/Files/Template/TemplateManager.php - line 160:OC\Files\Node\Folder->newFile()
  2. /var/www/html/nextcloud/apps/files/lib/Controller/TemplateController.php - line 56:OC\Files\Template\TemplateManager->createFromTemplate()
  3. /var/www/html/nextcloud/lib/private/AppFramework/Http/Dispatcher.php - line 218:OCA\Files\Controller\TemplateController->create()
  4. /var/www/html/nextcloud/lib/private/AppFramework/Http/Dispatcher.php - line 127:OC\AppFramework\Http\Dispatcher->executeController()
  5. /var/www/html/nextcloud/lib/private/AppFramework/App.php - line 157:OC\AppFramework\Http\Dispatcher->dispatch()
  6. /var/www/html/nextcloud/lib/private/Route/Router.php - line 302:OC\AppFramework\App::main()
  7. /var/www/html/nextcloud/ocs/v1.php - line 63:OC\Route\Router->match()
  8. /var/www/html/nextcloud/ocs/v2.php - line 24:require_once("/var/www/ht … p")|
    | — | — |

|Error|no app in context|OCP\Files\NotPermittedException: Could not create path

  1. /var/www/html/nextcloud/lib/private/Files/Template/TemplateManager.php - line 160:OC\Files\Node\Folder->newFile()
  2. /var/www/html/nextcloud/apps/files/lib/Controller/TemplateController.php - line 56:OC\Files\Template\TemplateManager->createFromTemplate()
  3. /var/www/html/nextcloud/lib/private/AppFramework/Http/Dispatcher.php - line 218:OCA\Files\Controller\TemplateController->create()
  4. /var/www/html/nextcloud/lib/private/AppFramework/Http/Dispatcher.php - line 127:OC\AppFramework\Http\Dispatcher->executeController()
  5. /var/www/html/nextcloud/lib/private/AppFramework/App.php - line 157:OC\AppFramework\Http\Dispatcher->dispatch()
  6. /var/www/html/nextcloud/lib/private/Route/Router.php - line 302:OC\AppFramework\App::main()
  7. /var/www/html/nextcloud/ocs/v1.php - line 63:OC\Route\Router->match()
  8. /var/www/html/nextcloud/ocs/v2.php - line 24:require_once("/var/www/ht … p")|
    | — | — |

Hope that helps

Thanks!
You need to make sure that the external drive has the correct permissions so that your webserver can write on that drive. If the drive is ext4, btrfs or zfs formatted, it should be something like:

sudo chown -R www-data:www-data /path/where/your/drive/is/mounted
sudo chmod -R 770 /path/where/your/drive/is/mounted

Obviously you need to modify /path/where/your/drive/is/mounted to fit your configuration.

The drive is formatted as ext4, should have said that earlier.

I have applied the permissions suggested but still can’t see the existing files/directories and can’t write to drive

Now getting the following error
Error PHP Error: opendir(/media/ubuntu/): failed to open dir: Permission denied at /var/www/html/nextcloud/lib/private/Files/Storage/Local.php#134

<>

OC\Log\ErrorHandler::onError()

/var/www/html/nextcloud/lib/private/Files/Storage/Local.php - line 134:

opendir()

/var/www/html/nextcloud/lib/private/Files/Storage/Common.php - line 878:

OC\Files\Storage\Local->opendir()

/var/www/html/nextcloud/lib/private/Files/Storage/Wrapper/PermissionsMask.php - line 158:

OC\Files\Storage\Common->getDirectoryContent()

<>

OC\Files\Storage\Wrapper\PermissionsMask->getDirectoryContent()

/var/www/html/nextcloud/lib/private/Files/Cache/Scanner.php - line 409:

iterator_to_array()

/var/www/html/nextcloud/lib/private/Files/Cache/Scanner.php - line 389:

OC\Files\Cache\Scanner->handleChildren()

/var/www/html/nextcloud/lib/private/Files/Cache/Scanner.php - line 341:

OC\Files\Cache\Scanner->scanChildren()

/var/www/html/nextcloud/lib/private/Files/View.php - line 1346:

OC\Files\Cache\Scanner->scan()

/var/www/html/nextcloud/lib/private/Files/View.php - line 1390:

OC\Files\View->getCacheEntry()

/var/www/html/nextcloud/apps/dav/lib/Connector/Sabre/Directory.php - line 331:

OC\Files\View->getFileInfo()

/var/www/html/nextcloud/3rdparty/sabre/dav/lib/DAV/CorePlugin.php - line 765:

OCA\DAV\Connector\Sabre\Directory->getQuotaInfo()

/var/www/html/nextcloud/3rdparty/sabre/dav/lib/DAV/PropFind.php - line 95:

Sabre\DAV\CorePlugin->Sabre\DAV{closure}("*** sensiti … *")

/var/www/html/nextcloud/3rdparty/sabre/dav/lib/DAV/CorePlugin.php - line 769:

Sabre\DAV\PropFind->handle()

/var/www/html/nextcloud/3rdparty/sabre/event/lib/WildcardEmitterTrait.php - line 89:

Sabre\DAV\CorePlugin->propFind()

/var/www/html/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php - line 1052:

Sabre\DAV\Server->emit()

/var/www/html/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php - line 984:

Sabre\DAV\Server->getPropertiesByNode()

/var/www/html/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php - line 1661:

Sabre\DAV\Server->getPropertiesIteratorForPath()

/var/www/html/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php - line 1646:

Sabre\DAV\Server->writeMultiStatus()

/var/www/html/nextcloud/3rdparty/sabre/dav/lib/DAV/CorePlugin.php - line 346:

Sabre\DAV\Server->generateMultiStatus()

/var/www/html/nextcloud/3rdparty/sabre/event/lib/WildcardEmitterTrait.php - line 89:

Sabre\DAV\CorePlugin->httpPropFind()

/var/www/html/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php - line 472:

Sabre\DAV\Server->emit()

/var/www/html/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php - line 253:

Sabre\DAV\Server->invokeMethod()

/var/www/html/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php - line 321:

Sabre\DAV\Server->start()

/var/www/html/nextcloud/apps/dav/lib/Server.php - line 332:

Sabre\DAV\Server->exec()

/var/www/html/nextcloud/apps/dav/appinfo/v2/remote.php - line 35:

OCA\DAV\Server->exec()

/var/www/html/nextcloud/remote.php - line 167:

require_once("/var/www/ht … p")

Any ideas?

Then I guess your nextcloud isn’t running as www-data user, is it?
What does sudo ls -l /var/www/html/nextcloud return?

drwxrwxr-x 43 www-data www-data 4096 May 6 18:13 3rdparty
drwxrwxr-x 48 www-data www-data 4096 May 7 13:29 apps
-rw-r–r-- 1 www-data www-data 17900 May 6 18:11 AUTHORS
drwxrwxr-x 2 www-data www-data 4096 May 7 14:42 config
-rw-r–r-- 1 www-data www-data 3900 May 6 18:11 console.php
-rw-r–r-- 1 www-data www-data 34520 May 6 18:11 COPYING
drwxrwxr-x 22 www-data www-data 4096 May 6 18:12 core
-rw-r–r-- 1 www-data www-data 5122 May 6 18:11 cron.php
drwxrwx— 5 www-data www-data 4096 May 11 12:59 data
-rw-r–r-- 1 www-data www-data 156 May 6 18:11 index.html
-rw-r–r-- 1 www-data www-data 2960 May 6 18:11 index.php
drwxrwxr-x 6 www-data www-data 4096 May 6 18:11 lib
-rwxr-xr-x 1 www-data www-data 283 May 6 18:11 occ
drwxrwxr-x 2 www-data www-data 4096 May 6 18:11 ocm-provider
drwxrwxr-x 2 www-data www-data 4096 May 6 18:11 ocs
drwxrwxr-x 2 www-data www-data 4096 May 6 18:11 ocs-provider
-rw-r–r-- 1 www-data www-data 3144 May 6 18:11 public.php
-rw-r–r-- 1 www-data www-data 5341 May 6 18:11 remote.php
drwxrwxr-x 4 www-data www-data 4096 May 6 18:11 resources
-rw-r–r-- 1 www-data www-data 26 May 6 18:11 robots.txt
-rw-r–r-- 1 www-data www-data 2446 May 6 18:11 status.php
drwxrwxr-x 3 www-data www-data 4096 May 6 18:11 themes
drwxrwxr-x 2 www-data www-data 4096 May 6 18:11 updater
-rw-r–r-- 1 www-data www-data 382 May 6 18:11 version.php

So the error still appears after you run

sudo chown -R www-data:www-data /media/ubuntu
sudo chmod -R 770 /media/ubuntu

?

OK, I can now upload files to the drive, but I still can’t see the files and directories that were already there.

So than you probably need to rescan the files by executing:
sudo -u www-data php -f /var/www/html/nextcloud/occ files:scan --all -vvv

That works, I can now access all of the existing files and directories, but oddly it seems to have created a new directory level, so WD>WD then the content. Is this normal?

I am not sure what you are seeing there. Could you post a screenshot or videocast of this?

So I get


At the first level
and
then at the second level

I was kinda expecting to go from the first level directly into the content of the external drive WD, but maybe that is just not the way it works?

I see. Can you share a screenshot of your external storage configuration?

This?

Yes :+1:
Easy fix: in the external storages configuration change the path to /media/ubuntu/WD and it should work.
(You might need to rescan the files with the command that I’ve sent above.)

That’s great! Thanks, all sorted now. :grinning:

1 Like