8

When I mount my SMB share via Nautilus, transfer speeds are slow. So I did some digging and found that when I mount the share via CLI and specifically set the protocol-version to 2.0, it's much faster.

Here is the command I use on the CLI:

sudo mount -t cifs -o vers=2.0,username=Lukas,password=xxxx,uid=1000,gid=1000 //nas/video /media/lukas/nas

How can I make Nautilus use Version 2.0 when mounting my share?

  • The Nautilus Version is "GNOME nautilus 3.26.3"
  • The Gnome Shell Version is "GNOME Shell 3.28.3"
  • Ubuntu Version is "18.04.1 LTS"
Lukas Knuth
  • 183
  • 1
  • 1
  • 6

2 Answers2

4

I have a alternate suggestion if you are interested. Instead of messing about with how the samba client accesses the NAS - which as I said should be unnecessary since it will use SMB2/3 by itself if required - why not just use CIFS automatically?

Add the following line to the end of /etc/fstab:

//nas/video /media/lukas/nas cifs vers=2.0,username=Lukas,password=xxxx,uid=1000,gid=1000,noauto,user 0 0

Note: The server can also be expressed as an mDNS qualified hostname if the server supports it: //nas.local/video Or an ip address: //192.168.0.100/video

How this will work:

noauto = will make it so that it doesn't mount at boot. We are going to set this up to use CIFS on demand when you need it - useful if you have a laptop.

user = will make it so an ordinary user ( non sudo ) can mount the share.

mount point = Since it's under /media it will induce a udisks response:

(1) An icon will appear on the side panel of Nautilus.

(2) It will be "actionable" - click on it and the system will go to fstab to find out how to mount it then mount it - click on it again to unmount the share.

There is a side benefit to this approach. The icon that it will add to Nautilus will also show up in most of your applications - like gedit > Open for example. Then you can mount the share from your application directly.

Note to anyone reading this: The mount point is important here. For the udisks magic to work the mount point has to be under /media or your home directory.

Morbius1
  • 7,261
  • 1
  • 15
  • 22
  • 1
    Nice, thanks. This is actually what I was looking for, didn't know that Nautilus picked up entries from `fstab`. I'll try it later! – Lukas Knuth Sep 05 '18 at 12:35
  • This works! **But**, the `//nas/video` makes it look like it works with hostnames which it doesn't! When trying this with hostnames it gives a silly error and doesn't mount. Only IP addresses seem supported here. See https://unix.stackexchange.com/a/152153/12737 I just fixed the DHCP lease for the NAS in my router. – Lukas Knuth Sep 05 '18 at 20:00
  • If you add the information from above, I'll accept this. – Lukas Knuth Sep 05 '18 at 20:05
  • I will add a note about using an ip address but I will offer another option as well. There is no reason why a manual mount using //hostname/video should be any different from an fstab mount. – Morbius1 Sep 05 '18 at 21:24
  • This is my fstab mount against a Windows 10 server: //vwin10.local/documents /media/Win10-Docs cifs username=smbuser,password=smbuserpw,uid=1000,iocharset=utf8,noauto,user 0 0 It will also work with just //vwin10/documents. An ip address is not required. – Morbius1 Sep 05 '18 at 21:28
  • I could not get it to work without an IP. See the linked thread. Even when I add the hostname to the hosts file it doesn't work. – Lukas Knuth Sep 06 '18 at 08:05
  • You can't get it to work without an IP address. But I can. If I alter my post to state that it can only be done by IP as an absolute it would be inaccurate because it will cover your case but not mine. Either way that has nothing to do with my suggestion of a noauto/user/fstab solution. If you have an issue with name resolution and CIFS I would suggest a separate question. – Morbius1 Sep 06 '18 at 10:29
  • Just a note that I added an answer to another question specifically referencing CIFS and host name resolution here: https://askubuntu.com/questions/663090/smbclient-finds-nas-but-mount-cant-find-it/1073444#1073444 It just seems more appropriately covered there because it was specifically asked. – Morbius1 Sep 08 '18 at 19:16
3

The short answer is Nautilus is already doing that. What you may be experiencing is the difference between CIFS ( controlled by the Linux kernel ) vs a gvfs / smbclient ( which Nautilus uses ) mount of the share. The CIFS method appears to be faster perhaps because of the overhead of gvfs.

The samba client being used by Nautilus will negotiate with the server to find the best SMB dialect to use between a "min" which predates SMB1 all the way up to a "max" of SMB3_11.

The Linux kernel starting with 4.13.5 will also negotiate with the server using CIFS between SMB2.1 and SMB3.

I suppose you could override what the samba client is doing naturally in Nautilus by adding the min value to /etc/samba/smb.conf but it shouldn't make any difference: Place this line in the [global] section like right under the workgroup = WORKGROUP line:

client min protocol = SMB2

There are different variants of SMB2: SMB2_02, SMB2_10, SMB2_22, SMB2_24. By default "SMB2" selects "SMB2_10" Just make sure you don't add anything for the max value.

EDIT: There seems to be some confusion as to where you place the "client min protocol" line - in the server or in the client. It has been suggested that it be in the server.

If I set up a 18.04 server and specified "client min protocol = SMB2" on the server then accessed it with a Ubuntu 16.04 client that by design can at best ( without modification ) only access the server with SMB1 ( aka NT1 ) here is the result of that access on the server:

xxx@srvub1804:~$ sudo smbstatus

Samba version 4.7.6-Ubuntu
PID     Username     Group        Machine                                   **Protocol**               
-------------------------------------------------------------------------------------
4681    nobody       nogroup      vub1604 (ipv4:192.168.1.140:45648)        **NT1**

There is no change as the client still accesses the server using SMB1 ( NT1 ).

If however I modify the client min / man setting on the client to "client min protocol = SMB2" and "client max protocol = SMB3" and remove the "client min protocol" from the server I end up where I expected:

xxx@srvub1804:~$ sudo smbstatus


Samba version 4.7.6-Ubuntu
PID     Username     Group        Machine                                   **Protocol**             
-------------------------------------------------------------------------------------
4915    nobody       nogroup      vub1604 (ipv4:192.168.1.140:45664)        **SMB3_11**

I think the confusion stems from another parameter called "min protocol" ( aka "server min protocol" ) which does in fact dictate what minimum dialect of smb is permissible for access. That one is done on the server. "client min/max protocol" is done on the client.

If you have a smb.conf on the client that's great. If not you can install it this way:

sudo apt install smbclient
Morbius1
  • 7,261
  • 1
  • 15
  • 22
  • Interesting, if you set only `min protocol = SMB2` it actually affects other systems, especially the way Windows browses the network, but if you make it the `client min protocol = SMB2` then Windows browses the network fine, and Windows 10 connects at 3.1.1. This was setting that on my Ubuntu 18.04 Samba. =) +1 – Terrance Sep 02 '18 at 00:03
  • The config-change you're proposing is done on the SMB Server, correct? Because on the client machine, I don't have that config file. – Lukas Knuth Sep 03 '18 at 07:15
  • It's done on the client. /etc/samba/smb.conf is present by default in Ubuntu. If for some reason it is not in yours install the following package: "sudo apt install smbclient" – Morbius1 Sep 03 '18 at 10:41
  • @LukasKnuth Yes, that file is on your server that is running your Samba shares. You don't need to set it on the client as when it connects to the server, the line `client min protocol = SMB2` causes the client to negotiate at SMB2. – Terrance Sep 04 '18 at 16:45
  • Please see the man pages for smb.conf regarding this option: "client min protocol (G) This setting controls the minimum protocol version that the client will attempt to use." It's to be added to the client not the server. How would you add it to a server running Windows? – Morbius1 Sep 05 '18 at 10:30
  • @Morbius1 Where does OP state that they are using a Windows Samba server? – Terrance Sep 05 '18 at 20:59
  • They didn't. "client min protocol" is a client side option as it controls how the client starts the smb dialog negotiation with the server. It makes no sense to put it on a server. As an example how would you put it on a Windows server? – Morbius1 Sep 05 '18 at 21:34
  • @Morbius1 Client side doesn't have to have Samba installed. I don't on my system. I do have a Samba server and setting that on the server side forces the client when connecting to connect at greater than SMB1.0. Samba server doesn't run on Windows. It is not installable. You can use the SMB Server protocols, but that is not Samba. Windows has its own file sharing. – Terrance Sep 05 '18 at 23:48
  • smb.conf doesn't come from the "samba" package. It comes from the samba-common-bin package which is installed by default because it's "common" to both the samba client and server. I don't know how to explain this any other way: client min/max directives like all the other directives that start with "client" are to be placed on the client not the server. – Morbius1 Sep 06 '18 at 11:52
  • Here is a practical example of this dynamic at work on an older version of Ubuntu: https://askubuntu.com/questions/919967/how-to-tell-gigolo-gvfs-to-use-smbv2-for-windows-shares/926451#926451 – Morbius1 Sep 06 '18 at 12:15
  • I am running 18.04 at work and it does not have `/etc/samba/smb.conf` on it as I don't have Samba installed. It is not installed by default. If I install Samba then the file will exist. I have been setting these servers up for a long time now. `apt-cache policy samba-common-bin` on this host that connects to Samba shares just fine returns `Installed: (none)` My original comment here is about if you set the `client min` on the Samba server it forces the SMB client to connect by default at greater than what is posted, and that is what worked and that is why I upvoted. – Terrance Sep 06 '18 at 22:26
  • The client side should always autonegotiate unless specified by using the vers= in the command as some servers that have been setup, like older Windows XP, that only supports SMB1.0. WIndows 10 defaults to 3.1.1 – Terrance Sep 06 '18 at 22:31
  • I have edited my original answer. – Morbius1 Sep 07 '18 at 12:11