Use NextCloud as an SMB share

Hi there,

I have a NAS and I’m using an SMB share to modify/copy/delete files.
Now I’d like to have those files available from NextCloud but I won’t have enough space on my laptop to have a copy using NextCloud Client, I’d like to be able to use both NextCloud from the UI when I need and be able to continue to use SMB.
If I change files using SMB share in NextCloudData folder, it’s not updated in NextCloud, so I had to run an occ command to get those changes.

Thanks in advance for any suggestions.

1 Like

It’s not recommended to directly access the data folder unnecessarily.

Have you considered setting up the SMB as external storage and then mounting via WebDAV from the client?

You can also use the desktop client and tell it not to sync that external storage, and then map a WebDAV drive directly to the subfolder of the external storage.

Hi Karl,
Thanks for your reply.
I didn’t consider mounting WebDav instead of SMB, so I’m gonna try this approach and report here if that works https://github.com/childrss/webdav

Tested this approach by attaching WebDav as a network share in Finder. Extreeeeemeeeeely slow. Any thought on improving WebDav experience?

WebDAV is not really cool and fast. Because of your problem you can perhaps use “plain webdav” and SMB with the same folder all without Nextcloud. Then it is perhaps faster and you do not need a MariaDB and scan the folder.

https://www.server-world.info/en/note?os=Debian_10&p=httpd&f=12

I last used WebDAV on Apache2 perhaps 10 years ago.
Perhaps you find a better documentation. Not tested.

If you use Nextcloud, SMB and plain webdav on the same directory, you can decrease the scan of nextcloud (-> to MariaDB) and use the performance of plain webdav.

Is it possible to make NextCloud to subscribe to modifications on the filesystem and apply them to it’s database? Like Java’s https://docs.oracle.com/javase/tutorial/essential/io/notification.html

To make NextCloud reactive towards any local changes rather than have to ask NextCloud to sync files.

If you use the normal Nextcloud-WebDAV it writes all changes also to the database.

Well I think what you’re overlooking is that isn’t how Nextcloud is intended to work. The idea is that you access your data through Nextcloud, not access Nextcloud’s data directly and expect it to keep up with manual edits to what’s supposed to be data it manages itself.

The files:scan function is there for you to correct inconsistencies or preload a user’s data, not so it can be run repeatedly after regularly manually modifying Nextcloud’s data. Going down that course will cause you problems.

So my guess is that your best course is to leave the data on the SMB share, and access the SMB share via Nextcloud’s web UI or WebDAV as needed. You can selectively sync with the desktop client too.

WebDAV does tend to be a bit slower than other methods. A virtual sync client that works more like Google File Stream was in development, but I don’t think it was stable yet.

If none of that is suitable, maybe it would be better to use a VPN to access the SMB share directly.

Gotcha. I understand that it’s not the way how NC was intended to be used. I just don’t understand why it was meant to allow the system to become out of sync. If I was a designer of a file management system (which NC in my understanding is), I’d have tried to build a sync process in its foundation, so that by default any file system event becomes known to the app and corresponding functions are triggered to react.

Perhaps Nextcloud is more a file sharing platform than a fileservice.

You can better use SMB as fileservice and nextcloud as file sharing platform.
Use perhaps SMB as external storage in nextcloud.
Differentiate between both storages.

https://docs.nextcloud.com/server/18/admin_manual/configuration_files/external_storage/smb.html

I have a similar goal (I think) to OP and perhaps a working solution.
*** I would love feedback on this proposal ***

I have a lot of files (home movies, music, etc) that I cannot afford to have replicated to my laptop. I would like them browseable and streamable from my media center PC and my windows laptop too, just as an SMB mount. WinDav has not worked well for me in this regard – The windows DAV driver cannot support files with more then 4.3GB.

I like the sharing and version control benefits of nextcloud. I need to have all my files backed up in two places anyway, so I am considering doing this:

Machine 1:
Raspberry Pi
Desktop Client Installed
External 4TB drive exported to windows laptop and media PC via SMB
External drive’s files are selected for synchronization in the desktop client.

Machine 2:
NextCloudPi Server
4TB External USB Hard Drive

My hope is:
1-The SMB shares from machine 1 will be directly viewable and editable by my laptop over SMB for those big files that I don’t want to sync.
2-The SMB filesystem will be monitored by machine 1’s desktop client and notify the nextcloud server of the changes.
3-The Nextcloud server (2) will keep track of revisions to those files in case I do something dumb.

I think this MIGHT accomplish what the OP was asking about if they don’t mind having backups.
Thoughts???

1-The SMB shares from machine 1 will be directly viewable and editable by my laptop over SMB for those big files that I don’t want to sync.

that has nothing to do with Nextcloud

2-The SMB filesystem will be monitored by machine 1’s desktop client and notify the nextcloud server of the changes.

Nextcloud can use SMB as external storage. But there is no notification to nextcloud.

3-The Nextcloud server (2) will keep track of revisions to those files in case I do something dumb.

It is SMB and not Nextcloud storage. That is not the goal of Nextlcoud to track of revisions for external storage like SMB.

@devnull Thank you for taking the time read my post and respond.

On point 1 - True. It was provided for background information.
On point 2- I’m sorry I wasn’t clear. The SMB share is mounted on machine 1 as a local drive. Those folders will be set for replication to nextcloud in the desktop client just as if they resided on its hard drive locally. They are NOT mounted with the external storage option in NextCloud. I haven’t done the experiment yet; however I think it should work.
On point 3 - Same clarification as for 2. Since I won’t be using the “external storage” option within nextcloud to mount it, but will instead be monitoring it with the desktop client, I expect the desktop client to pick up file changes just like it would with any other local filesystem.

Does that help clarify what I am considering doing?

The only thing I can think of that would cause this to not work is if the desktop client uses some sort of “anti-virus” like software hook to only ever look at files that the desktop client is directly accessing and that it never goes back and does a comprehensive scan. I don’t know how the desktop client works internally.

If you only change the files via Nextcloud, this will work as intended.
If you on the other hand change files via a different client over SMB or on the SMB-server directly, you will need to let Nextcloud rescan the files since the files will no longer be as Nextcloud expects them to be.