Talk:Linux CIFS Utils and Samba

From Free Knowledge Base- The DUCK Project: information for everyone
Jump to: navigation, search

What is SMB, NetBIOS etc.? by Jacco de Leeuw

Jacco de Leeuw wrote a brilliant article explaining Microsoft Windows networking and Samba going back to protocols and terminology I worked with in the 1990s. Again, absolutely brilliant.

What is SMB?

In order to communicate, you and I need a common language, like English or Swahili. Computers are no different. There are a few basic "languages" computers use to communicate on a network, and these languages are called protocols. TCP/IP, NetBEUI, IPX, SNA and Appletalk are examples of protocols.


One of the most popular protocols for PCs lets you share files, disks, directories, printers, and (in some cases) even COM ports across a network: this protocol is called the SMB (Server Message Block) standard. Microsoft is trying to rename SMB-based networking to "Windows Networking" and the protocol to "CIFS" but I'll stick to SMB in the following.


An SMB client or server can communicate with just about any other similar program that adheres to this SMB standard including Warp Connect, Warp 4, LAN Server, Lan Server/400, IBM PC Lan and Warp Server (from IBM), LANtastic in SMB mode (from Artisoft), MS-Client, Windows for Workgroups, Windows 95, LAN Manager and Windows NT Workstation & Server (from Microsoft), DEC Pathworks, LM/UX, AS/UX, Syntax and Samba.



Whoa! That's a lot of products from a lot of vendors. Can they all work together?


In short, yes. You can take clients and servers from any of the above and mix and match. The limitations are licensing, and protocols. Although the exact capabilities will vary, since many vendors have 'extended' the SMB protocol into "dialects", you should be able to share at least printers and files with any SMB compatible system. However, some dialects offer more features than others. When you connect to another machine, both have to compromise to the "highest common dialect". This means that sometimes you don't have access to all the features you would like.



Now I know what SMB is, what is NetBIOS then? And NetBEUI?


SMB-based networks use a variety of underlying protocols, but the most popular are "NetBIOS over NetBEUI" and "NetBIOS over TCP/IP" (also called RFC/Netbios or TCPBEUI).


A SMB client or server expects a NetBIOS interface. In other words, it uses (or thinks it uses) the same method of communicating with any other SMB system no matter what type of protocol is used underneath. Think of NetBIOS as a passenger and TCP/IP, NetBEUI, IPX, and SNA as different types of vehicles (like airplanes, automobiles, buses, etc). The vehicle carries the passenger from point A to point B. Likewise, the protocol carries NetBIOS (and other) passengers across a computer network.



What's the problem with NetBEUI?


NetBEUI (called "IBM OS/2 NETBIOS" in Warp 4 and Warp Connect) is basically NetBIOS pushed straight onto the network. It would be like asking the passenger to walk from point A to point B without taking any vehicle at all. NetBEUI likes to shout a lot. (A typical conversation: "Hey, everybody! I'm Machine #12! I'm looking for Windows 95 Machine #8! Answer me, #8!" ... "Here I am, Machine #12!"). NetBEUI is very fast, but all the shouting makes it "chatty." By default, older versions of Windows and OS/2 Warp (and most other SMB networking systems) will use NetBEUI as the default protocol because it needs almost no additional configuring.



Why, and when, do I need the "NetBIOS over TCP/IP" protocol?


It turns out that there are advantages to using TCP/IP, IPX, or some other protocol as the underlying communication between computers. NetBIOS can be carried by these protocols. They prefer not to "shout" (broadcast) and encourage sending direct messages.


"NetBIOS over TCP/IP" has become the most popular of these protocols. TCP/IP, of course, is the protocol used on the Internet, so many systems already have it installed and configured correctly. In fact, Samba even requires "NetBIOS over TCP/IP". It doesn't support "NetBIOS over NetBEUI" (however, code has been donated by a company which implements this).


Since "NetBIOS over TCP/IP" runs over the TCP/IP, you can even share drives and printers over the Internet. This is of course a big security risk so most users prefer to install a personal firewall to prevent this, or they remove the NetBIOS 'binding' on the Internet interface (see next paragraph.


If you open the "Network" configuration window in recent versions of Windows, you might have noticed that there is no option for "NetBIOS over TCP/IP". There is a "NetBEUI" entry, with which Microsoft actually means "NetBIOS over NetBEUI". If you install the TCP/IP protocol, Windows automatically installs the "NetBIOS over TCP/IP" protocol too. If you do want the TCP/IP protocol, but not "NetBIOS over TCP/IP" (because you're worried about security), you should uncheck "Files and Printer Sharing" in the Bindings tab of the TCP/IP entry in Network Configuration.



Can I use OS/2 as an SMB client to connect to Windows NT, Windows for Workgroups etc?


Yes. Warp 4 and Warp Connect can speak to any or all of them. TCP/IP, NetBEUI, and IPX are built in to OS/2 Warp 4, and other protocols can be added. Also built into Warp 4 is a program called the "IBM File and Print Client" (called "IBM Peer" in Warp Connect).


If you don't have Warp 4 or Warp Connect, you can use the free Microsoft LAN Manager Client for OS/2 instead. Read this for more information.



Can I share my files/printers/etc with other WfWg, NT, Lan Manager, OS/2 Warp etc. clients?


The answer depends on what version of OS/2 you use and what you are willing to spend.


OS/2 Warp 4 and Warp Connect have full peer to peer functionality called OS/2 Peer. It interacts with IBM Lan Requester, NT, WfWg, LAN Manager Client, Lan Manager, Samba and other SMB-based networks. This is the easiest, all-in-one package, solution. Upgrade from older OS/2 versions if you've got the money.


The LAN Manager client used to have this functionality, until Microsoft announced NT. The Client for OS/2 mysteriously lost this functionality at that time. On the positive side, you can download this software for free (I haven't seen that older version with limited peer to peer anywhere -- JdL). So you can't use the LAN Manager Client for sharing your own resources.


Artisoft used to offer another peer-to-peer solution, called Lantastic for OS/2 but it's not supported anymore. It can connect to Lan Manager, Lan Server, NT, WfWg etc.


As a last resort, you could use the OS/2 version of Samba. However, it only supports "NetBIOS over TCP/IP". This means you must already have a working TCP/IP stack. Warp 4 and Warp Connect both come with a TCP/IP but there is probably not much point in using them with Samba/2 because these versions of Warp also already come with SMB/NetBIOS support. When you are using OS/2 2.x with IBM TCP/IP v2.0, or Warp 3 with FreeTCP, then this might be an option. In that case, see this for more instructions on how to set it up.



How about the MSIPX protocol to connect to NT or NetWare servers running it?


"NetBIOS over IPX" is also called IPXBEUI or MSIPX. In Warp 4 and Warp Connect you'll find it as "NetWare NetBIOS Emulation over IPX". IPX is most commonly used with Novell NetWare servers. It is not available with the LAN Manager Client for OS/2.

kernel change fks fstab

The solution is to tell mount.cifs to use the SMB2, SMB2.1 or SMB3.0 protocol:

mount -t cifs ... -o vers=3.0,...

or vers=2.1 or vers=2.0.

From man mount.cifs :

      vers=
          SMB protocol version. Allowed values are:
          ·   1.0 - The classic CIFS/SMBv1 protocol. This is the default.
          ·   2.0 - The SMBv2.002 protocol. This was initially introduced in
              Windows Vista Service Pack 1, and Windows Server 2008. Note
              that the initial release version of Windows Vista spoke a
              slightly different dialect (2.000) that is not supported.
          ·   2.1 - The SMBv2.1 protocol that was introduced in Microsoft
              Windows 7 and Windows Server 2008R2.
          ·   3.0 - The SMBv3.0 protocol that was introduced in Microsoft
              Windows 8 and Windows Server 2012.
          Note too that while this option governs the protocol version used,
          not all features of each version are available.

//apollo/video/ /mnt/video cifs defaults,vers=1.0,domain=workgroup,username=nicolep,password=mythtv,iocharset=utf8,sec=ntlm 0 0

Using Gigolo to Mount Remote Samba Shares

https://forums.linuxmint.com/viewtopic.php?t=52144 [Using Gigolo to Mount Remote Samba Shares]


STEP 1: Prerequisites

Make sure the following packages are installed. If they are not then install them:

Code: Select all

sudo apt-get install gigolo sudo apt-get install gvfs-fuse

STEP2: Initial configuration

Launch gigolo then go to Edit > Preferences

G-General.png

G-Interface.png

G-Toolbar.png

Then Close Preferences and select the "View" button: enable: "Toolbar", "Side Panel", and "Status Icon"

STEP 3: Network Browsing

When you open up gigolo click on the Network tab on the side panel and it will eventually show you all your workgroups and all the hosts within those workgroups. Once you find the share you're looking for simply double click to mount it. A dialog box will open asking for the following information:

Service type: Windows Share Server: It should be auto filled Share: It should be auto filled Username: Only required if your remote share requires credentials.

The remote share should be displayed in the right panel of gigolo and double clicking the share will open a file manager so you can access it's contents.

STEP 3a: Connecting Directly to a Specific Machine

You don't have to browse to the remote machine you can connect to it directly by name or ip address:

Gigolo > Actions > Connect > Service Type = Windows Share > Server

In the "Server" Box you can put the remote machine name or ip address ( which will allow for a faster connect if you have static ip addresses on your boxes ). The "Share" combo box should then list all the available shares to that box once the "reload" button is selected.

STEP 4: ( OPTIONAL ) Auto Mounting Remote Shares on Boot

First: Set gigolo to start at login. Create a new entry in StartUp Applications:

Gnome: Menu > Preferences > StartUp Applications > Add > Command = gigolo

Mint Cinnamon: Menu > System Tools > System Settings > Startup Programs > Add > Command = gigolo

XFCE: Menu > Settings > Session & Startup > Application Autostart > Add > Command: gigolo

LXDE: Copy /usr/share/applications/Gigolo to /home/user-name/.config/autostart

Note: If you don't have an autostart folder cteate one:

Code: Select all

mkdir /home/user-name/.config/autostart


Second: Once you access the remote share using the method described above in STEP 3, you can set this up to mount the remote share automatically:

In the right side panel of gigolo right click the remote share and select "Create Bookmark" There you can give it a short bookmark name as well as other authentication information you want to pass to the server on boot. The versatility of this utility comes in when you enable the "Auto-Connect" option. This will do two things:

(1) If the server having the remote share is not up at the time you boot, the "Auto-Connect" option will probe the network at an interval specified by the "Bookmark Auto-Connect Interval" you set in STEP 2 and then mount the share.

(2) The other thing it will do is reconnect to the share if the connection to the server is interrupted for whatever reason.

Note: The Auto Mount will happen at login so there is no need to reboot to see if it works as advertised. Just logout and log in again.

STEP 5: ( OPTIONAL ) Mount Point

There is one downside to all this goodness however. At it's core it's still using a "gvfs-mount smb://" mechanism to mount the remote share. That means it will create a mount point in a hidden directory at this location with this type of path:

   /home/your_user_name/.gvfs/share_name on host_name

In Mint14 it gets a little more complicated. The mount point moves to something like this:

   /run/user/your-user-name/gvfs/smb-share:server=host_name,share=share_name

You can create a bookmark to the .gvfs or gvfs folder so that is shows up in the Open and Save boxes:

Run the following command:

Code: Select all

nautilus $HOME/.gvfs

Or on Mint14:

Code: Select all

nemo /run/user/your-user-name/gvfs

      • Bookmark that location: Bookmarks > Add Bookmark
      • Right click the resulting ".gvfs" or "gvfs" bookmark > Rename and rename to LanShares for example. It should then be visible in your application as LanShares.

ADDITIONAL BENEFITS

Ubuntu has changed the way services are started and when things are mounted and as a result it has introduced a number of bugs. As it turns out, gigolo can actually work around a couple of them.

BUG 1: fstab is executed before the network is up.

The traditional way of automounting a remote share is to add a line in fstab that will execute on boot. The problem is that because of the changes Ubuntu has made, fstab sometimes executes before the network is up. There used to be a parameter "_netdev" that one could add to the fstab expression but that no longer reliably works. The "Auto-Connect" option in gigolo solves this problem by periodically probing the network and mounting when the share is available on the network.

BUG 2: Shutdown hangs when a remote share is mounted.

If you have a remote share mounted in the traditional manner, shutting down the system hangs because the network is shut down before the mountpoints are unmounted. Gigolo works in userspace. At shutdown the system will logoff the user first and will automatically unmount the remote share before passing to the root level shutdown sequence which shuts down the network.

UPDATE: As pointed out by member jan_goyvaerts below, when using LMDE XFCE:

   Then, you may need to add the following lines to your ~/.local/share/applications/defaults.list so that Thunar is used to open folders by gvfs-open:
   x-directory/gnome-default-handler=Thunar.desktop
   inode/directory=Thunar.desktop
   x-directory/normal=Thunar.desktop

using smbcredentials

and

terzag says A solution would be to mount the Samba shares from your NAS, so that they’ll be seen as directories and should be browsable from Firefox (or other softwares that can’t browse the network).

I mount my NAS shares with lines like this in my /etc/fstab file:

//192.168.0.15/Videos	/media/qnap-ts128a/videos	cifs	credentials=/etc/nas-credentials,vers=2.0,iocharset=utf8,uid=1000,gid=1000	0	2


  • the first part is the local address of the Samba share to mount
  • the second part is the mount point (you have to create the dir first, of course); note that there are two directories made specifically for mounting: /media (the mount point will automatically appear in the panel of the file manager) and /mnt (it will not appear in the panel)
  • cifs is the filesystem to use for Samba shares; you might have to install the cifs-utils package, I don’t remember if if’s there from the start on Ubuntu
  • the credentials file is a text file containing two lines, username=xxx and password=yyy for the share; you can also specify both options rather than having a file; if your shares are allowed for guest, I don’t think you need this
  • vers=2.0 is an option of CIFS to manage some versions of Samba; depending of the one used by your NAS, it might differ
  • uid and gid are my user id, it means that the share is mounted on a directory as belonging to me; if you have multiple users on your system, this will need to be managed differently
  • 0 and 2 are mount options; keep them like this

Note that when added to the fstab, the shares are mounted during boot. Which means that the network has to be accessible at that time. So if you’re on a laptop (or even a desktop PC) that connects to the network through wi-fi, it won’t work, as the connection will be made after the desktop is loaded and won’t be accessible during boot.