Skip to content
This repository has been archived by the owner on Dec 1, 2018. It is now read-only.

Use SMB vers=2.1 instead of vers=1.0 when mountain Windows shares #66

Closed
xinity opened this issue Dec 28, 2015 · 22 comments
Closed

Use SMB vers=2.1 instead of vers=1.0 when mountain Windows shares #66

xinity opened this issue Dec 28, 2015 · 22 comments
Assignees

Comments

@xinity
Copy link

xinity commented Dec 28, 2015

hi,

reading a lot about smb support on linux kernel and windows 7/8, i found that shared folders using smb are mounted using smb vers=1.0 which far slower than smb >2

see here:
http://blogs.technet.com/b/josebda/archive/2008/12/09/smb2-a-complete-redesign-of-the-main-remote-file-protocol-for-windows.aspx

why not providing an option to use a better protocol than smb1 on windows computer ?

what do you think ?

@lmakarov
Copy link
Owner

Hi @xinity,

I did not realize there were different SMB protocol versions around...

Looks like they are up to SMB 3.0 in Windows 8:
http://blogs.technet.com/b/josebda/archive/2012/06/06/windows-server-2012-which-version-of-the-smb-protocol-smb-1-0-smb-2-0-smb-2-1-or-smb-3-0-you-are-using-on-your-file-server.aspx

Unfortunately, my quick googling did not bring any decent result on how exactly one can check the protocol version in use and how to enforce a specific one.

Can you provide examples (check protocol version, enforce protocol version)?

@xinity
Copy link
Author

xinity commented Dec 28, 2015

kind of simple they are all activated by default :
windows 7 : smb protocol version supported 1,2,2.1
windows 8: smb protocol 3+

the server (windows hosts) talks to the client using the version supported by the client .
in our case (boot2docker vagrant) windows7 talks to the boot2docker VM (kernel v4+) using v1 (by default no option passed to mount using cifs protocol enforces version1), but can also talk using smb 2.1

to test, you can change in the vagrantfile, the mount options to force smb version with the parameter:
Windows 7: "vers=2.0" or "vers=2.1"
Windows 8: "vers=3.0"

hoping this helps,

@lmakarov
Copy link
Owner

@xinity I tried those with no luck. Only vers=1.0 would mount, all other versions will give an error, e.g.:

$ sudo mount -t cifs //192.168.10.1/projects /c/projects -o uid=`id -u docker`,gid=`id -g docker`,noperm,nounix,actimeo=2,username=vagrant,pass=vagrant,dir_mode=0777,file_mode=0777,vers=2.1
mount: mounting //192.168.10.1/projects on /c/projects failed: Invalid argument

I assume the Tinycore Linux distro (used by boot2docker) only supports SMB 1.0 ...

@xinity
Copy link
Author

xinity commented Dec 28, 2015

Strange as smb implementation is related to kernel version which is 4.0.9 on tiny core.....

I'll see what I can find

@achekulaev
Copy link
Contributor

@lmakarov
possible solutions

  1. check the case (is it //192.168.10.1/projects or //192.168.10.1/Projects?
  2. try adding sec=ntlm option
sudo mount -t cifs //192.168.10.1/projects /c/projects -o sec=ntlm,uid=`id -u docker`,gid=`id -g docker`,noperm,nounix,actimeo=2,username=vagrant,pass=vagrant,dir_mode=0777,file_mode=0777,vers=2.1
  1. try adding unc option
... -o unc=\\\\192.168.10.1\\projects,...
  1. try mounting without uid, gid
  2. sometimes it helps to
    sudo apt-get install cifs-utils and then remount

@xinity
Copy link
Author

xinity commented Dec 29, 2015

thanks alexei,

i'll try mouting this morning and so how it goes

i'll let you know guys,

Le mar. 29 déc. 2015 à 02:12, Alexei Chekulaev notifications@github.com a
écrit :

@lmakarov https://github.com/lmakarov
possible solutions

  1. check the case (is it //192.168.10.1/projects or //
    192.168.10.1/Projects?
  2. try adding sec=ntlm option

sudo mount -t cifs //192.168.10.1/projects /c/projects -o sec=ntlm,uid=id -u docker,gid=id -g docker,noperm,nounix,actimeo=2,username=vagrant,pass=vagrant,dir_mode=0777,file_mode=0777,vers=2.1

  1. try mounting without uid, gid
  2. sometimes it helps to
    sudo apt-get install cifs-utils and then remount


Reply to this email directly or view it on GitHub
#66 (comment)
.

@xinity
Copy link
Author

xinity commented Dec 29, 2015

update:
it seems to be related to tinycore itself, tried with a fresh debian weezy and mounting a cifs shared folder with option : vers=2.1 works perfectly

@lmakarov
Copy link
Owner

lmakarov commented Jan 8, 2016

So I tried this with mount.cifs (via the cifs-utils, which had to be installed manually because of the unmet dependencies):

wget http://repo.tinycorelinux.net/6.x/x86_64/tcz/samba-libs.tcz
wget http://tinycorelinux.net/6.x/x86_64/tcz/filesystems-3.16.6-tinycore64.tcz
wget http://tinycorelinux.net/6.x/x86_64/tcz/cifs-utils.tcz
tce-load -i samba-libs.tcz filesystems-3.16.6-tinycore64.tcz cifs-utils.tcz

The result is the same - I'm not able to set the vers parameter to anything other than 1.0
Also tried misc options @achekulaev suggested in #66 (comment)

@xinity did you do some tests to compare the performance difference SMB 1.0 vs 2.1?
A substantial difference would justify further efforts to make it working on tinycore.

Switching off of tinycore to debian would mean a major overhaul of the project and a custom docker-machine/boot2docker image, and I'm not up to that (yet).

@xinity
Copy link
Author

xinity commented Jan 12, 2016

until, we haven't found (very strangely) any performance boost switching from smb1 to smb2 ou smb2.1 (using debian jessie VM with docker installed).

FWIW tinycore seems to be too restrictive and not docker oriented, maybe we can switch to coreOS ou rancherOS which uses docker built-in ....

@Koriit
Copy link

Koriit commented Jan 14, 2016

@lmakarov
Regarding performance. Many devs passionately explain that 'CIFS != SMB != SMB2' like they have almost nothing in common. As a matter of facts I just took it for word but just now was able to find some SMB2 vs SMB tests.

Daniel Schuhmann wrote(actually that was almost 9 years ago!):

Version 1 of this protocol, which is still in use today, was developed 15 years ago and was introduced with Windows 3.11 for Workgroups. Since the fastest networks in use at the time generally offered a maximum transfer rate of 10 Mb/s, the protocol has become out of date. Indeed, with Gigabit Ethernet interfaces now a common feature even on budget motherboards, SMB can’t keep up with current network speeds.

Meaning SMB1 in the very concept is just slow, according to today's standards.

The same man also run some comparison tests. Well, we don't know the exact test environment, it was done 9 years ago and even on Windows Server 2008, but I guess it can give some insights. What we want is actually protocols comparison, anyway.

Daniel Schuhmann's test:
http://www.tomshardware.com/reviews/WINDOWS-SERVER-2008-REVIEWED,1710-8.html

Diagram 1

Diagram2

So, as far as insights go, then... Well, you know.

Anyway, I've been trying to install/use/force/select/whatever later versions of SMB protocol for several days now, and still no success. If you happen to succeed please, give me a bump.

@xinity
Copy link
Author

xinity commented Jan 14, 2016

@Koriit we run some tests using a debian jessie with the docker engine installed and made some performance test.
we found (strangely) that cifs version higher then version1 seems to be slower !!
cifs v1 ~ 20sec
cifs v2+ ~ 35sec

test were made with symphony apps

i can't figure out why , if you guys have any clues, please share with us :)

@Koriit
Copy link

Koriit commented Jan 14, 2016

@xinity I understand that you are sharing between linux and win hosts, then linux uses cifs mount with vers=2.0/2.1 and what about windows? Which windows and how configured is the SMB protocol? As far as I know Win7 has support for SMB in versions 1.0, 2.0, 2.1 and probably 2.2 which is almost equivalent to 3.0. Then, Win7 should seamlessly adjust to the connected peer but I don't know how it works with Win8+.

@xinity
Copy link
Author

xinity commented Jan 14, 2016

windows 7 host (server) and linux (client)
tests made using cifs vers option : 1.0 , 2.0 and 2.1
--> windows 7 doesn't support 2.2 (vers3.0) and higher

we have also adjusted parameters of SMB on windows like max queue et frame size, to allow bigger transfer

the server adjust regarding options used on the client.

@Koriit
Copy link

Koriit commented Jan 14, 2016

What volumes of data were you sharing?

@xinity
Copy link
Author

xinity commented Jan 14, 2016

several GB from 2 to 5gb at max !

Le jeu. 14 janv. 2016 à 11:39, Aleksander Stelmaczonek <
notifications@github.com> a écrit :

What volumes of data were you sharing?


Reply to this email directly or view it on GitHub
#66 (comment)
.

@Koriit
Copy link

Koriit commented Jan 14, 2016

Then I have no other ideas. Might be funky implementation, some other related(or not) mechanisms or environment or anything, rly. :/

@lmakarov
Copy link
Owner

I did some testing with the debian/jessie64 Vagrant box on a Windows 10 host.

  1. All SMB protocol versions seem to work (v1.0, 2.0, 2.1, 3.0)
  2. There was no notable difference in performance between different versions (using Drupal CMS site install as a test case)

Strangely, the debian box overall performance was slower than the TinyCore one in the same test case.
Both had 2GB of RAM allocated and had a similar configuration.
I guess there might be other differences in VBox config and optimizations between the two.

Based on the testing done here there seems to be no point in perusing this any further.

Closing. Feel free to reopen if anyone figures out a way to get more out of a newer (v2.0+) SMB protocol version.

@shripatel
Copy link

Thanks, @lmakarov https://github.com/lmakarov
Your, possible solutions solved our trouble.

@fabricek
Copy link

fabricek commented Feb 26, 2018

Thanks, @lmakarov who help me to solve the problem. Better than installing an old samba protocol (v1.0), it's better to compile a new boot2docker iso which contents new samba version 2 and above. Go to https://github.com/boot2docker/boot2docker and clone the project. Modify the kernel.config file to enable samba 2. Set CONFIG_CIFS_SMB2=y. Build the docker image as usual and get the new boot2docker iso as described. We can now use the command with vers parameter : mount -t cifs ...., ,vers=2.1 without error and share folders with windows 10.
(Note that vers parameter is tied on linux kernel. vers 2.1 works at the time of writing. But for a 3.0 we must use a more recent linux kernel.)

@lmakarov
Copy link
Owner

@fabricek huge thanks for pointing to the CONFIG_CIFS_SMB2=y kernel option!
After building a custom boot2docker.iso image with that kernel flag enabled it is indeed possible to use the vers=2.1 argument and mount Windows host shares via SMB2.

Using vers=3.0 does not work, even though CONFIG_CIFS_SMB2=y should be covering that as well (reference).

I also tried the experimental CONFIG_CIFS_SMB311=y (reference), but that one does not seem to be working at all (can only use vers=1.0 with it).

Anyway, anything newer than SMB1.0 is good, since SMB1.0 is now deprecated and disabled by default starting with Windows 10 Fall Creators Update 1709. It has to be enabled manually and possess security risks for the host machine (see docksal/docksal#382).

@fabricek
Copy link

I think we have to update the linux kernel in dockerfile to have vers=3.xx working. I thought modify the dockerfile with this value "ENV KERNEL_VERSION 4.4.116" to the last version. You can see it at https://www.kernel.org/pub/linux/kernel/v4.x and linux-4.9.9.tar.gz for example. So ENV KERNEL_VERSION should be 4.9.9 in dockerfile. Take a look at it.
Anyway i didn't do that because i don't know all the consequences when compiling the new boot2docker iso (what about the tinycore kernel and dependancies. Have we to build them with the new linux core ? https://github.com/on-prem/tinycore-kernel )
vers=2.1 is enough to me for the moment so i prefer to wait a new update with a new linux kernel to the boot2docker/boot2docker github project. As you said "anything newer than SMB1.0 is good" But if you really want vers=3.xx hope this will help you to go further.

@lmakarov lmakarov changed the title mounting use smb vers 2.1 instead of 1.0 Use SMB vers=2.1 instead of vers=1.0 when mountain Windows shares Jun 29, 2018
@lmakarov lmakarov reopened this Oct 18, 2018
@lmakarov lmakarov self-assigned this Oct 18, 2018
@sulikdada
Copy link

Mountain :D

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

7 participants