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"

2 Answers 2

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.

8
  • 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! Sep 5, 2018 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 unix.stackexchange.com/a/152153/12737 I just fixed the DHCP lease for the NAS in my router. Sep 5, 2018 at 20:00
  • If you add the information from above, I'll accept this. Sep 5, 2018 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 5, 2018 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 5, 2018 at 21:28
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
13
  • 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 2, 2018 at 0: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. Sep 3, 2018 at 7: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 3, 2018 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 4, 2018 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 5, 2018 at 10:30

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .