Make Nautilus mount SMB share with Protocol 2.0

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"

Solution 1:

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.

Solution 2:

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