How do I get files added directly to a Linux external SMB share to show in NC

Support intro

Sorry to hear you’re facing problems. :slightly_frowning_face:

The community help forum (help.nextcloud.com) is for home and non-enterprise users. Support is provided by other community members on a best effort / “as available” basis. All of those responding are volunteering their time to help you.

If you’re using Nextcloud in a business/critical setting, paid and SLA-based support services can be accessed via portal.nextcloud.com where Nextcloud engineers can help ensure your business keeps running smoothly.

Getting help

In order to help you as efficiently (and quickly!) as possible, please fill in as much of the below requested information as you can.

Before clicking submit: Please check if your query is already addressed via the following resources:

(Utilizing these existing resources is typically faster. It also helps reduce the load on our generous volunteers while elevating the signal to noise ratio of the forums otherwise arising from the same queries being posted repeatedly).

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:

The Basics

  • Nextcloud Server version (e.g., 29.x.x):
    • 31.0.7
  • Operating system and version (e.g., Ubuntu 24.04):
    • Debian 12
  • Web server and version (e.g, Apache 2.4.25):
    • 2.4.62 (Debian)
  • Reverse proxy and version _(e.g. nginx 1.27.2)
    • HAProxy in pfSense
  • PHP version (e.g, 8.3):
    • 8.2.28
  • Is this the first time you’ve seen this error? (Yes / No):
    • Yes
  • When did this problem seem to first start?
    • today
  • Installation method (e.g. AlO, NCP, Bare Metal/Archive, etc.)
    • Bare Metal/Archive
  • Are you using CloudfIare, mod_security, or similar? (Yes / No)
    • No

In NC, I have an external SMB share pointing to an OMV server. I put some files directly into the SMB share using SCP but they didn’t show up in NC. I googled around and ran runuser -u www-data -- php occ files:scan --all. This completed with:

Starting scan for user 1 out of 4 (admin)
Starting scan for user 2 out of 4 (alex)
Starting scan for user 3 out of 4 (nick)
Starting scan for user 4 out of 4 (rachel)
+---------+-------+-----+---------+---------+--------+--------------+
| Folders | Files | New | Updated | Removed | Errors | Elapsed time |
+---------+-------+-----+---------+---------+--------+--------------+
| 1505    | 5260  | 0   | 9430    | 0       | 0      | 00:00:55     |
+---------+-------+-----+---------+---------+--------+--------------+

And the files didn’t show up. What should I have done when adding the files like that?

I gave up and added the files through the web interface.

hey @nickh

hmmm that sounds like an SMB permission issue. is the SMB share mounted as admin and made available for the users via external files? try adding the same share per user in external files, with each users SMB credentials.

otherwise mount the SMB share into the host via fstab as root, and then connect to the hosts local share via external files…

you’re not using the snap that’s clear, but this may help understand: How to add samba shares and local shares to Nextcloud snap

All the permissions are correct:

-rw------- 1 alex users  35522 Aug 27  2024 Alex_XXX_CV_AM.docx
-rw------- 1 alex users 158813 Jul 28 17:41 Alex_XXX_CV_AM.pdf
-rw------- 1 alex users  35522 Aug 27  2024 Alex_XXX_CV_AM_V1.docx
-rw------- 1 alex users  35597 Jul 28 17:40 Alex_XXX_CV_AM_V2.docx

But the third file does not show up and I see:

root@mail-www:/var/www/nextcloud# runuser -u www-data -- php occ files:scan alex
Starting scan for user 1 out of 1 (alex)
+---------+-------+-----+---------+---------+--------+--------------+
| Folders | Files | New | Updated | Removed | Errors | Elapsed time |
+---------+-------+-----+---------+---------+--------+--------------+
| 1473    | 3557  | 0   | 9       | 0       | 0      | 00:00:28     |
+---------+-------+-----+---------+---------+--------+--------------+

I can confirm that if I map the OMV share directly, I can see the file, so it is just NC that is not picking it up. The issue is both the NC desktop app and the web app.

Nextcloud requires permissions to www-data:www-data to access the files.

I am not sure of the relevance of the comment. NC is running on a Debian machine and has www-data:www-data ownership. Samba is running on a different machine running OpenMediaVault. In OMV the permissions are alex:users which is also correct. If I map the share directly I can see all four files I listed. NC can only see 3 of them, missing the one I added by SFTP. Even if I trigger a rescan in NC, the file remains missing in NC.

Hi @nickh

As @Mornsgrans and @scubamuc have pointed out, this sounds like a (Unix) permissions issue (or a Unix “ownership” issue, anyway).

I’m not sure what this means; I’m going to assume it means:

  • I have two servers
  • One runs OMV; one runs Nextcloud (on Debian)
  • The former is serving an SMB/CIFS share
  • …which is mounted by Debian on the latter

You’re right that runuser -u www-data -- php occ files:scan --all is the command to make Nextcloud scan for new files :+1:

…But I think you might be confusing different types of users(?)

Are you sure? The permissions where…? The permissions as they appear to the OMV server, or the permissions as they appear to the Nextcloud server?

Nextcloud user != Unix user

…So a Nextcloud user called “alex” is a different type of thing from a Unix user called “alex”; does that make sense?

The point is:

If you want Nextcloud to be able to “see” the files, then as far as the OS (i.e. Debian) on your Nextcloud server is concerned, the files need to be owned by www-data i.e. the web server user.

Can I make a suggestion? If the only thing that mounts that share is your Nextcloud instance, why not dispense with SMB/CIFS and just use NFS instead? NFS (v3) is a simpler protocol than SMB/CIFS; I suspect it would be easier. (The same thing applies, though: as far as the OS on your Nextcloud server is concerned, the files you’re mounting - whether you’re using NFS, SMB/CIFS or something else - need to be owned by “www-data”).

I hope that helps; best of luck.