Samba is a collection of networking tools to provide network resources in a Windows network. These can be shares of directories and printers that Samba provides and regulates client access to the services. Samba is not limited to Windows clients. Just as well Linux and Apple PCs can use the network shares.
Overview: Samba on Raspberry Pi
With Samba you can realize almost all the functions you would expect from a Windows network.
- Setup file and directory shares with Samba
- Advanced Samba configuration
- Samba Troubleshooting
- Setup printer shares with Samba
- Primary Domain Controller for NT (Samba 3)
- Active Directory Domain Controller (from Samba 4)
SMB – Server Message Block
The eponym for Samba is the Server Message Block (SMB) protocol. SMB is a protocol for transferring data between a client and a server. Following the client-server principle, all actions are taken by the client. The client sends a request to the server. It processes the request and makes the requested data or services available. Under Samba, the functions of SMB are provided by the daemon (service) “smbd”.
The smbd service not only provides file and print services but also provides authentication and authorization capabilities to protect username and password shares, for example.
Since 1996, Microsoft has introduced an extension called CIFS (Common Internet File System), which offers additional services in addition to file and printer sharing. To date, the SMB and CIFS protocols are used synonymously.
NetBIOS is the protocol responsible for name resolution on the Windows network. It is provided under samba by the daemon (service) “nmbd”.
The service “nmbd” takes care of the name resolution and the “Browsing”, ie the possibility to search for and display available shares in the network.
Difference between Samba 3 and Samba 4
Samba is available in different versions. Usually you will work with Samba 4. In some Linux distributions but still Samba 3 can be up to date. The differences between Samba 3 and 4 are in the details, which usually are not that important. For simple directory shares, both versions are fine.
Samba 3 already supports LDAP, which also supports the Windows Active Directory introduced with Windows 2000. However, Samba 3 can not replace an Active Directory domain controller. Only with the version 4 Samba is a free implementation of the directory service Active Directory of Microsoft. This means that with Samba 4 you can set up an Active Directory domain controller.
Version 2 (SMB2) of the SMB protocol was introduced with Windows Vista. Since Samba 3.5 there is experimental support for SMB2. Since Samba 3.6, the SMB2 protocol is fully supported.
Since Windows 7, the SMB version 3 is used. This is supported since Samba 4. But not all functions. It can be assumed that in the course of time, the range of functions will increase.
An important feature of SMB3 is the encryption of data transmission, which is supported by Samba 4.
Samba 4.3 talks about SMB version 3.1.1, which Microsoft introduced with Windows 10. It promises greater security in the negotiation of SMB dialects and functions.
Under Raspbian Wheezy only Samba 3 is available. That’s fine if you can do without an Active Directory domain controller. For easy directory sharing, Samba 3 will do just fine. Since a domain controller would be completely oversized.
If you use Raspbian Jessie, you should also use Samba 4. Even if you only need a simple file server. The basic configuration of Samba 4 is much easier. In addition, Samba 4 is the only version that is still being actively maintained.
All functions and features provided by Samba via the SMB protocol and NetBIOS are set via the central configuration file “/etc/samba/smb.conf”. Here, all shares of directories or printers and the control of permissions are set.
sudo nano /etc/samba/smb.conf
Control Samba services
Samba consists of two services. Namely “smbd” and “nmbd”. And that’s exactly what you have to consider when starting, stopping, restarting the services and reloading the configuration. If necessary, you have to treat both services separately.
sudo service smbd start sudo service smbd stop sudo service smbd restart sudo service smbd reload sudo service nmbd start sudo service nmbd stop sudo service nmbd restart sudo service nmbd reload
Note: It may be advisable to only reload the configuration (“reload”). When restarting services, all clients lose connection to the server. This can lead to data loss.
Most problems are caused by incorrect or incomplete configuration of the Samba server, incorrect file and directory permissions, and incorrect username and password authentication.
Extension: Automatically mount / mount Samba shares with “fstab”
In principle, a Samba share always consists of two pages. The server side and the client side. The Samba server was configured successfully in the best case. Now it’s about setting up or automatically mount the shared directory to the local file system of a client or other server.
Advanced Samba configuration
A simple file or directory share is set up with Samba with little configuration overhead. There are, however, other optional configuration options.