OCC file scan error

[/details]

Nextcloud version (eg, 12.0.2):17.0.1
Operating system and version (eg, Ubuntu 17.04):18.04
Apache or nginx version (eg, Apache 2.4.25): 2.4.41
PHP version (eg, 7.1): 7.3

The issue you are facing:

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

Steps to replicate it:

  1. Fresh NC 17 installation
  2. External HDD mounted with data directory in it
  3. Rescanning of files

The output of your config.php file in /path/to/nextcloud :


<?php
$CONFIG = array (
  'instanceid' => '',
  'passwordsalt' => '',
  'secret' => '',
  'trusted_domains' =>
  array (
    0 => 'localhost',
  ),
  'datadirectory' => '/media/sda1/nextcloud',
  'dbtype' => 'mysql',
  'version' => '17.0.1.1',
  'overwrite.cli.url' => 'localhostnextcloud',
  'dbname' => '',
  'dbhost' => 'localhost',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'mysql.utf8mb4' => true,
  'dbuser' => '',
  'dbpassword' => '',
  'installed' => true,
  'maintenance' => false,
  'memcache.local' => '\\OC\\Memcache\\APCu',
  'memcache.locking' => '\\OC\\Memcache\\Redis',
  'redis' =>
        array (
                'host' => '/var/run/redis/redis-server.sock',
                'port' => 0,
                'timeout' => 0.0,
        )
);

OCC file scan error

:+1: Great request.

    sudo -u www-data php occ files:scan --all

returns

    Starting scan for user 1 out of 1 (user)
Home storage for user user not writable
Make sure you're running the scan command only as the user the web server runs as

So now it seems I can access the external storage, but the file scan still throws errors.

Hi!
Owncloud is writing as the user of the webserver.

Is the www-data account able to write there?

You can check it with the following command:

sudo -u www-data mkdir /media/sda1/nextcloud/test

If it succeed you will have a folder called test on your harddrive and we verified that it is not a permission issue. If it fails you need to check the permissions on your drive.

Thanks for the quick response. ls -l gets me
drwxrwx--- 1 www-data www-data 4096 Dec 9 15:50 files for the directory files. Permissons should be correct.

No problem!

Ok if you preform the same action inside your data folder.

Is the owner also www-data for the folders inside that? Just to verify that everything has the same ower/group.

Yes. Do permissions additionally have to be set to 0770?

All permissions are set now for all subfolders. Could it be that the mountoptions in fstab have to be adjusted?

Fstab mount:
/dev/sdb1 /mnt/sda1 ntfs default,permissions 0 0
ls -l

total 6653
drwxrwx--- 1 www-data www-data     512 Jan  4 14:25  appdata_ocswe1bwdxez
drwxrwx--- 1 www-data www-data       0 Jan  3 16:00   folder
drwxrwx--- 1 www-data www-data    4096 Jan  3 16:14  folder
drwxr-xr-x 1 www-data www-data     160 Jan  4 14:21  files_external
drwxrwx--- 1 www-data www-data       0 Jan  3 16:14  folder
drwxrwx--- 1 www-data www-data    4096 Jan  3 16:16  folder
-rwxrwx--- 1 www-data www-data       0 Jan  4 13:37  nextcloud.log
-rwxrwx--- 1 www-data www-data 6747640 Nov 10 21:00 'Nextcloud Manual.pdf'
-rwxrwx--- 1 www-data www-data   37042 Nov 10 21:00  Nextcloud.png
drwxrwx--- 1 www-data www-data    4096 Jan  3 16:18  folder
drwxrwx--- 1 www-data www-data       0 Dec 24 14:10 '$RECYCLE.BIN'
drwxrwx--- 1 www-data www-data       0 Jan  1 17:26 'System Volume Information'
drwxrwx--- 1 www-data www-data    4096 Jan  3 16:20  folder
drwxrwx--- 1 www-data www-data    4096 Jan  3 16:20 folder

Still the occ command throws the same error. Has this something to do with the user for which the scan runs? I´m at the end of my wits here.

Permission problems are usually best be analyzed be switch to the web server user, navigation through the directory tree and trying to create a file in a directory, like

1. su - www-data -s /bin/sh

2. cd /media/sda1/nextcloud
3. touch ./xyz
4. if the file can is being create yo can delete it afterwards:
   rm ./xyz
5. repeat the steps 3-5 with the users directory
   cd /media/sda1/nextcloud/<user>
   ... 
6. scan the directory with verbose output enabled:
   ./files:scan -vvv <user>

Thank you for your reply. Creating all the files and deleting seems to be no issue. Yet the filescan error persists.

What also is strange that uploding files via webinterface gets me a Forbidden error.

Does this work with ntfs? Or do I have to use ext4?

fdisk -l yields

Disk /dev/sdb: 1.8 TiB, 2000398934016 bytes, 3907029168 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0xc1ce985b

Device     Boot Start        End    Sectors  Size Id Type
/dev/sdb1  *     2048 3907026943 3907024896  1.8T  7 HPFS/NTFS/exFAT

So I resolved my issue by formatting the disk into ext4 fs and it worked flawless since then.

1 Like