Samba – Compatibility with Windows When Case-Sensitive Names Are Enabled

sambaserver-message-blockwindows

I want to have a *nix Samba share accessible by Windows clients.

Samba has an option to enable or disable filename case-sensitivity. Normally for windows access, this is disabled, so that fred==FRED=fReD.

However, this leads to one major gotcha, AFAICT:

  • On unix, you create two folders
    called "RODDY" and "roddy"
  • On Windows, you'll see both of the
    folders, but…
  • When you delete/rename/open one from Windows,
    you could end up
    deleting/renaming/etc either of them.
    You have no way of knowing which!.

So, my question is, how does Samba behave on windows if the case-sensitive flag is set "ON"? Can a user still see both folders, and have file operations work in a consistent manner?

Best Answer

It should be fine. Windows Explorer does a fine job of displaying filename case correctly. I use this in my smb.conf to make sure what I type in Explorer is what Samba uses (I set all of these per-share):

case sensitive = True
default case = lower
preserve case = yes
short preserve case = yes

I ran through a quick test (Samba 3.0.24 on the backend, WinXP on the front). Files were created on the samba server via an SSH session.

$ cd /some/samba/share/path
$ mkdir test
$ cd test

$ mkdir test1 TEST1
$ touch test1/foo TEST1/bar

After this, I browsed through my mapped drive to the test directory. I can see both "test1" and "TEST1" directories. I opened "test1" and saw the "foo" file. I opened "TEST1" and saw the "bar" file. So far so good.

Then I went back to the test directory, and in the Explorer window, renamed TEST1 to TEST2. Windows freaked slightly -- it renamed the folder, then showed BOTH folders as TEST2 -- appearing to have renamed both folders. But, in the SSH terminal, I checked:

$ ls
test1 TEST2

So Windows renamed the file, and Samba got the filename correctly. When I pressed F5 in the Explorer window to refresh the folder contents, the display changed to show the correct folder names.

Caveat: Linux filesystems allow some characters that Windows doesn't (like ":"). Samba has a "name mangling" option to turn those filenames into something Windows will like. If I make a file called "FA:23" in my SSH window, for example, Samba mangles the name to "F7T4H0~F" and that's what appears in the Explorer window.