smb.conf variable %m doenst work with mount.cifs

Posted on

Problem :

I noitice a difference between mount.cifs and gvfs when connection to my samba server.

Entry in smb.conf I like to connect to …

[backup]
path = /srv/smb/backups/%m
comment = Inkrementelle Backups vom System
browseable = no
guest ok = no
writeable = yes
valid users = bak
inherit owner = yes

Notice the %m in path !

When using nautilus (gvfs) every thing works as expected.

But %m gets ignored when using mount.cifs.

A picture say more than 1000 words …
https://photos.app.goo.gl/VZoz8bXUhqjaxeIi2

How to get mount.cifs behave like gvfs ?

I tried to change the protocol to 1.0, 2.0, 2.1 and 3.0 but nothing changed at all.

Has it some to do with NetBIOS, because I dont use it, instead I use dhcp & bind. Maybe I have a wrong bind configuration, but I cant find any error messages.

Solution :

We’re talking about

%m
the NetBIOS name of the client machine

This parameter is not available when Samba listens on port 445, as clients no longer send this information. If you use this macro in an include statement on a domain that has a Samba domain controller be sure to set in the [global] section smb ports = 139. This will cause Samba to not listen on port 445 and will permit include functionality to function as it did with Samba 2.x.

(source).

Then there is this mount option in man 8 mount.cifs:

netbiosname=arg
When mounting to servers via port 139, specifies the RFC1001 source name to use to represent the client netbios machine name when doing the RFC1001 netbios session initialize.

Thus I think you should mount with:

mount -t cifs -o credentials=/root/.smbcredentials,netbiosname=…

You can also add port=139 option. This way mount won’t lose time trying to connect on port 445.

Leave a Reply

Your email address will not be published. Required fields are marked *