Corrupt Files From an SMB External File Source

Hello All,

Putting this issue here as I have been going absolutely crazy trying to fix it - now that I have I thought I’d share.

Issue is trying to download an xlsx file from external files on an SMB share would succeed but the content would be completely scrambled. Upon further inspection, it seems that the issue was occurring on random files all over the filesystem, regardless of size or type. Browsing from windows explorer had no issues at all. Copying a file which corrupts in nextcloud to a new file would now suddenly work - i.e. downloading the file through nextcloud would yield an uncorrupted file.

SMB mount was from Server 2016 share.
Server is Ubuntu 16.04, running php7, nextcloud is v11.0.1

Noticed on Server 2016, that the affected files were marked with “SparseFile” and “ReparsePoint” attributes. Remembered Dedupe was turned on for that volume - but dedupe should work, it’s supposed to be transparent to the client. Ok undeduped single file, bam now it works. Hmmmm… not about to dedupe the whole volume let’s check smbclient.
Check smb sessions on file server, all sessions coming from nextcloud are 1.0 dialect - wow ok didn’t even know that was still supported.
Set in /etc/samba/smb.conf:
client min protocol = SMB3
client max protocol = SMB3

(For some reason if you don’t set max to SMB3 as well it doesn’t work)

using smbclient from the command line right away picked up the new settings in conf but on nextcloud I’m not sure if I had to force close all the smb sessions so they reopen or whatnot. Anyways system was not prod so I just rebooted. Bam everything works now.

I put this up because as people move to dedupe this might become more common. Also I don’t understand why in 2016 Ubuntu still defaults to lowest possible negotiated smb dialect - it’s been a problem since forever but whatever it’s working now.

Maybe this’ll help someone one day

Thanks for posting this! I was having the same issue with dedupe on Server 2016!