Solved Samba 4.1 on FreeBSD 10.1: Duplicate Objects is Shared Directory Listings

This is very strange, I've been using Samba4.1 for a while and everything (apart from previous versions) was fine but I was forced to do a fresh install moving onto 10.1 as freebsd-update killed my 10.0 install. So everything was fine before my reinstall but software levels are now the most current unfortunately I have no reference of the older working versions.

As stated before configs have stayed the same but I've moved onto the latest software versions within the ports tree. i.e. samba41-4.1.14, ntp-4.2.8_3.

Another difference is that I bumped the ZFS version to the latest offered by 10.1.

Enough back story onto the symptoms, I now get a single object in every directory view duplicated. The object that is duplicated is either a file or a directory. You can stop the duplication by renaming the object but the duplication moves onto another seemingly random file or folder in the view. Renaming the troubled object back to its original name recreates the situation on that item. Time stamp etc on the duplicated items prove the object is somehow presented twice.

This behaviour is also present browsing the server through other clients, Windows 8.1, Windows 10 Preview and Windows 7 I have tested and witnessed the same behaviour.

It's a very strange one I'd like to clear up. Any help would be great.

Unfortunately this didn't work, duplicate objects still exist when browsing with SMB only. NFS and SFTP show the contents without issue. This issue does look similar but I haven't proven the symptom of losing objects in large directories.

The problem version of SMB is samba41-4.1.14 from ports, the previous working version was samba41-4.1.13 current at the time of install.
Hmm... As one more last ditched effort to see if it is related, can you try putting the directory name cache size = 0 under each share you have defined in /usr/local/etc/smb4.conf?

The Debian bug report above mentions it should be added on a "per share basis".
Yeah, I spotted that and gave both a try. Still no luck. I'll try a reinstall from packages.
So I'll be reinstalling FreeBSD 10.1 tonight. I can't fix this and is playing havok for Windows clients.
OK... still a problem after fresh install of 10.1 and install of Samba from pkgs. This has to be a bug, I'll try reverting to FreeBSD 10 tomorrow but that might be a problem with my ZFS upgrade while at 10.1.
OK... still a problem after fresh install of 10.1 and install of samba from pkgs. This has to be a bug, I'll try reverting to FreeBSD 10 tomorrow but that might be a problem with my ZFS upgrade while at 10.1.
If, after upgraded to 10.1, you did a ZFS upgrade, then I don't think you will be able to use that drive on 10.0 due to the new feature flags.

Also, I don't think a FreeBSD reinstall often helps with issues with ports/packages.

Have you tried posting on the Samba mailing lists / forums?
silkie: Please have a look at and especially at all options with "cache" in their name. Do you have any of them enabled? I had a very nasty performance problem a few days ago that was caused only by one single flag (not "case sensitive = yes" in that case) in my /usr/local/etc/smb.conf.
How many files are there in these directories? Is this a problem on all shares or just on one of them?
Could you please provide some more information about the options you set within your /usr/local/etc/smb4.conf? Maybe try settings like shown here:
Hi all, Sorry for leaving this so long. So testing completed so far. woodsb02: you where dead right, reinstalling was a waste of time. As was trying to role back to 10.0 because of my zfs upgrade. I was just getting pissed at the situation and not thinking clearly.

I have tweaked the life out of my smb4.conf, performance is exceptional, even now but please see my global section and example of a share.

In addition I have setup a new share on the new zfs dataset on a ufs partition just to rule out the FS. Both new testing shares still exhibit this new behaviour as do all the others. As soon as I have greater than 1 file or folder in a share one of those objects is duplicated. The duplication only happens the once in the current viewing branch regardless of the number of objects in a directory. This behaviour is repeated on every branch down the directory tree. Bloody strange! Never seen before in many years playing with this stuff.

Global Section:
  workgroup = xxxx
  realm = INTERNAL.xxxx.xxxx
  netbios name = BSSS
  server role = active directory domain controller
  dns forwarder =
  interfaces =
  bind interfaces only = yes
  server services = rpc, nbt, wrepl, ldap, cldap, kdc, drepl, winbind, ntp_signd, kcc, dnsupdate, dns, smb
  dcerpc endpoint servers = epmapper, wkssvc, rpcecho, samr, netlogon, lsarpc, spoolss, drsuapi, dssetup, unixinfo, browser, eventlog6, backupkey, dnsserver, winreg, srvsvc
  idmap_ldb:use rfc2307 = yes
  nsupdate command = /usr/local/bin/samba-nsupdate -g

  aio write size = 1
  aio read size = 1
  write cache size = 1048576
  socket options = TCP_NODELAY IPTOS_LOWDELAY SO_RCVBUF=524288 SO_SNDBUF=524288
  strict sync = no
  sync always = no
  use sendfile = true
  min receivefile size = 16384
  strict locking = no
  read raw = yes
  write raw = yes

  os level = 99
  wins support = yes
  name resolve order = wins bcast
  wins proxy = yes
  domain master = yes
  preferred master = yes
  unix extensions = no

  log level=3

Share Section:
  read only = No
  writable = Yes
  create mask = 0775
  directory mask = 0775
  vfs objects = shadow_copy2
  shadow: format = @daily-%Y-%m-%d
  shadow: sort = desc
  shadow: snapdir = .zfs/snapshot
  shadow: localtime = Yes
  veto files = Thumbs.db
  delete veto files = yes

Over to the Samba bugzilla site with me I think... I'll report back anything that fixes the situation.
I got the same issue, but it does not seem to happen when I use robocopy under DOS in a Windows machine. Investigating this further.
Well, I've got the same problem after updating to FreeBSD 10.1.
I did not upgrade ZFS pool yet, the problem is obviously not ZFS feature flags related.
Samba was 4.1.6 and was working fine for months. The problem with "double view" on SOME folders occurred right after upgrading FreeBSD from 10.0-Release to 10.1-Release.
First, the freebsd-update went terribly wrong with thousands of segfaults after first restart (kernel upgrade) and I had to re-install base manually. I think faults might be related to Samba's winbind which I stupidly stopped to speed-up freebsd-update.
After the update and almost reinstallation my old Samba 4.1.6 started to double some folders. "Doubled" folders have same content and if I log on to FreeBSD server I see only one folder, so, the doubling is "virtual" and I thought it is Samba-related. I did not recompile/upgrade Samba first and I thought this is side effect of outdated libraries or so.
After upgrading Samba (I recompiled it via ports-mgmt/portmaster) the problem disappeared first but today I've got a complaint from the user for the same behavior...
I think there is some connection between folder doubling and FreeBSD 10.1. Just to be sure I ran freebsd-update IDS to check if the OS files are correct.
As others have mentioned this is indeed fixed by:
directory name cache size = 0
and this bug been around at least since 8.X (ZFS only based on my experience at least).

If you're just running smbd this config has worked good on several boxes (XP, Win7 clients):
workgroup = fluffball.local
server string = Storage Server Fluffball
security = user
preferred master = yes
reset on zero vc = yes
log file = /var/log/samba.log
max log size = 10240
dns proxy = no
bind interfaces only = true
interfaces = em0
server max protocol = SMB3
directory name cache size = 0
load printers = no
disable spoolss = yes
printing = bsd
printcap name = /dev/null
unix extensions = no
nt acl support  = yes
inherit acls = no
map acl inherit = yes

comment = Fluffball's Storage Pool FluffShare
path = /vault0/fluffshare
public = yes
guest ok = yes
writable = yes
write list = fluffadmin
browseable = yes
create mask = 0775
vfs objects = zfsacl
nfs4:mode = special
nfs4:acedup = merge
nfs4:chown = yes
What OS are you running on the clients? Sounds really odd that this doesn't work, is this share off a ZFS system or something else?
I've tested again the directory name cache size = 0 theory against Windows 7, Windows 8.1, Windows 10 TP, Windows Server 2008 clients and they all experience this object duplication (Directories or files, only ever a single object duplicated in any one view). I have also tested this from a ZFS backed smb share and a UFS backed share. I haven't yet submitted a problem ticket with Samba but think this is a genuine bug now more people are reporting this.
Don't, there is already a ticket about this and something really odd as the directory name cache size has worked for pretty much everyone else. I'm running servers on both 10.1 and -HEAD/-CURRENT without any issues.
Fair enough, well I'm available for further investigation if/when required. I've kinda grown used to the situation, like a third leg or something, it just trips me up now and again. At least this server is only for personal use.
Hi diizzy - Please share the bugzilla ticket this as already been logged under... I'm failing too find it. At least I'm failing to find a duplicate file bug report with these exact symptoms.

I think this is a very old and it's not related to our problem.

In the meantime I've migrated some Samba3 and built some new Samba4.1 servers with FreeBSD 10.1 and ZFS. All the servers are AD domain members and I've not observed any folder or file duplication (yet...).
I'm not using directory name cache size in smb4.conf

Samba4 documentation does not recommend to use same server as AD DC and file server:
We do not recommend using the Domain Controller as a file Server. This is due to issues with the winbind internal to the Domain Controller. The recommendation is to run separate file or Member Servers.

I followed an advise by Sebulon to use a virtual AD DC with UFS+ACLs and (in my case) a file server on the real machine with ZFS, set as AD member. You can see it here:

I'd like to spare some visualization but this seems a good working solution by now.
Last edited by a moderator:
I like this, thanks for posting the suggestion. I have to run a Windows 2008 based VM for vCenter stuff on my file server anyway (recent requirement). So I'll make that my AD Master and set the ZFS File Server as a member and report back ASAP.
I like this, thanks for posting the suggestion. I have to run a Windows 2008 based VM for vCenter stuff on my file server anyway (recent requirement). So I'll make that my AD Master and set the ZFS File Server as a member and report back ASAP.

I have built such working solutions, with Server 2003, 2008 and 2012 as AD domain controller. Visualization makes proprietary systems much more hardware independent and eases backup and maintenance. FreeBSD is pretty much hardware independent for real. I would prefer my precious domain controller - the source of authentication for clients - to be open source - based to avoid dependency of vendor's policy anyway.
Building virtually-based AD DC with FreeBSD makes backup DCs unnecessary for single-site based organisations - the virtual machine can be easily moved on different real machines.

Now I am thinking how can I do it. NFS link between the AD master and ZFS storage server, or install the ZFS storage server as an AD member server.

In my opinion both solutions might have advantages but Samba natively supports everything necessary for AD DC and member. Using NFS would make administration much more complicated I think.
Last edited by a moderator:
I think this is a very old and it's not related to our problem.

Samba4 documentation does not recommend to use same server as AD DC and file server

This had been driving me nuts for months, so I wanted to bump the thread to confirm that running a file server and domain controller on the same FreeBSD 10.x box causes duplicate files/folders in listings, regardless of whether you're browsing the shares on Windows, *nix, or even Android. It's an obnoxious regression since provisioning a domain is easy, well documented, and impressively fool-proof, but joining an existing domain is less so. Especially since samba-tool purports to allow such a feat, but it doesn't actually work.

admdwrf's links are about the only things that come up in Google for configuring kerberos, NSS, winbind, etc. absent samba-tool magic, and they were adequate for setting up a non-DC file server with working directory listings.