Bug 5151 - Bug: Mounting multiple shares on same samba server with different servernames
Summary: Bug: Mounting multiple shares on same samba server with different servernames
Status: RESOLVED FIXED
Alias: None
Product: CifsVFS
Classification: Unclassified
Component: kernel fs (show other bugs)
Version: 2.6
Hardware: All Linux
: P3 regression
Target Milestone: ---
Assignee: Steve French
QA Contact:
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-12-18 11:19 UTC by Charlie
Modified: 2016-02-25 22:25 UTC (History)
0 users

See Also:


Attachments
screenshot demonstrating how to mount the same share name from two different servers colocated on the same ip address (168.79 KB, image/png)
2016-02-25 22:25 UTC, Steve French
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Charlie 2007-12-18 11:19:59 UTC
A small problem when a single samba server is exporting multiple shares under multiple netbiosnames and you want to mount more than one of them at a time. 

Here's the background:

I have a couple of Samba servers set up to share differently named shared on the same NIC, using the include %L syntax. For example:

[global]
        workgroup = oahusmb
        netbios aliases = st mt
        server string = GNU/Linux Samba
        smb ports = 139
------------8<-------------
        include = /etc/samba/smb.conf.%L

In /etc/samba/smb.conf.st:

[global]
        netbios name = ST
------------8<-------------      
[home]
        volume = home
        path = /home/st
        guest ok = yes
        writeable = yes
        create mask = 777

And in /etc/samba/smb.conf.mt:

global]
        netbios name = MT
------------8<-------------      
[home]
        volume = home
        path = /home/mt
        guest ok = yes
        writeable = yes
        create mask = 777

I can mount them both /at the same time/ using smbmount. But if I try the same with mount.cifs I get the second share mounting the same directory as the second:

charlie:/home/charlie# mount.cifs //st/home t1 -o guest,servern=st
charlie:/home/charlie# mount.cifs //mt/home t2 -o guest,servern=mt,
charlie:/home/charlie# ls t1
admin                    database  Equal Opps Data Interns 2006-07.ods  Health & Safety  IT    web
Campaign Supporters.lnk  design    Finance                              Human Resources  team
charlie:/home/charlie# ls t2
admin                    database  Equal Opps Data Interns 2006-07.ods  Health & Safety  IT    web
Campaign Supporters.lnk  design    Finance                              Human Resources  team
charlie:/home/charlie# 

Other salient data is as follows:
charlie:/home/charlie# cat /proc/fs/cifs/DebugData
Display Internal CIFS Data Structures for Debugging
---------------------------------------------------
CIFS Version 1.49
Active VFS Requests: 0
Servers:
1) Name: 192.168.254.202  Domain: OAHUSMB Mounts: 2 OS: Unix  
        NOS: Samba 3.0.24       Capability: 0x80f3fd
        SMB session status: 1   TCP status: 1
        Local Users To Server: 1 SecMode: 0x2 Req On Wire: 0
MIDs:

Shares:
1) \\mt\home Uses: 1 Type: NTFS DevInfo: 0x0 Attributes: 0x2b
PathComponentMax: 255 Status: 1 type: 0 
2) \\st\home Uses: 1 Type: NTFS DevInfo: 0x0 Attributes: 0x2b
PathComponentMax: 255 Status: 1 type: 0 


charlie:/home/charlie# /sbin/modinfo cifs
filename:       /lib/modules/2.6.22-2-amd64/kernel/fs/cifs/cifs.ko
version:        1.49
description:    VFS to access servers complying with the SNIA CIFS Specification e.g. Samba and Windows
license:        GPL
author:         Steve French <sfrench@us.ibm.com>

Hope you can help!
srcversion:     30616BA7D30E1F22CF9B850
depends:        
vermagic:       2.6.22-2-amd64 SMP mod_unload 
parm:           CIFSMaxBufSize:Network buffer size (not including header). Default: 16384 Range: 8192 to 130048 (int)
parm:           cifs_min_rcv:Network buffers in pool. Default: 4 Range: 1 to 64 (int)
parm:           cifs_min_small:Small network buffers in pool. Default: 30 Range: 2 to 256 (int)
parm:           cifs_max_pending:Simultaneous requests to server. Default: 50 Range: 2 to 256 (int)


charlie:/home/charlie# /sbin/mount.cifs -V
mount.cifs version: 1.10-3.0.26a

oahu:~# smbd --version    
Version 3.0.24
oahu:~# nmbd --version
Version 3.0.24
Comment 1 Charlie 2008-01-21 09:17:59 UTC
This is really irritating now that debian lenny has replaced smbmount with a wrapper round mount.cifs 

I use multiple netbios aliases on port 139, which ought to work AFAICS. hmmph
Comment 2 Rich 2008-05-23 10:26:18 UTC
Now that unbuntu Hardy has also ditched smbfs I cannot access any of the shares in my office! Please can someone have a look at this as it's a pretty darn serious bug, IMHO.
Comment 3 Charlie 2008-05-29 06:37:27 UTC
Being as it looks like this isn't going to be fixed soon, here's a workaround. Use multiple virtual IPs and <a href="http://charlieharvey.org.uk/dbpage.pl?id=56">alias by IP rather than NETBIOS name</a>. 

 
Comment 4 Charlie 2008-05-29 06:39:34 UTC
Ah. no html then. Here's what the previous comment should have said

Being as it looks like this isn't going to be fixed soon, here's a workaround.
Use multiple virtual IPs and alias by IP rather than
NETBIOS name. See: http://charlieharvey.org.uk/dbpage.pl?id=56
Comment 5 Steve French 2016-02-25 22:23:59 UTC
This worked fine for me - did you specify "servern" (or servernetbiosname) in the cifs mount options?  I created a set of smb.conf files as you described, both with the same share "me" but mapped to a different directory for smb.conf.mt and smb.conf.st. I also appended st and mt to localhost in /etc/hosts so both names would be mapped to the same server ip address (in this case localhost's 127.0.0.1) but this is not strictly necessary as the servers will be distinguished by their netbios name if using port 139.


Then I did 
   mount -t cifs //mt/me /mnt1 -o servern=MT
and
   mount -t cifs //st/me /mnt2 -o servern=ST
and got the expected result (the files in /mnt1 come from a different share than those in /mnt2)

See attached screenshot.  Key step is remembering to use "servern=MT" vs. "servern=ST" in the mount cifs options depending on which share you want to access.
Comment 6 Steve French 2016-02-25 22:25:24 UTC
Created attachment 11871 [details]
screenshot demonstrating how to mount the same share name from two different servers colocated on the same ip address