Follow by Email

Blog Archive

Search This Blog

Youtube Videos

Featured post

Set up print server with CUPS and AirPrint on Raspberry Pi

Set up print server with CUPS and AirPrint on Raspberry Pi CUPS (Common Unix Printing System) is a multi-standard open source printi...

Recent PostAll the recent news you need to know

Samba on the Raspberry Pi

Samba on the Raspberry Pi

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.

Samba Troubleshooting

Samba Troubleshooting

Most problems are caused by incorrect or incomplete configuration of the Samba server, incorrect file and directory permissions, and incorrect username and password authentication.
  • Start or stop samba properly
  • User authentication failed
  • No file and directory permissions
The following solutions are not to be understood as step-by-step instructions, but require knowledge of the basic Samba configuration.
Troubleshooting: Start or stop Samba properly
The following commands do not seem to work.
sudo service samba start
sudo service samba stop
sudo service samba restart
sudo service samba status

Sometimes the following error even comes up: "Failed to start samba.service: Unit samba.service is masked." What does that mean? This means that the service / service called "samba" does not actually exist.

You have to know that Samba consists of two services. Namely "smbd" and "nmbd". And that's exactly what you have to consider when starting, stopping and restarting. If necessary, you have to treat both services separately.
sudo service smbd start
sudo service smbd stop
sudo service smbd restart

sudo service nmbd start
sudo service nmbd stop
sudo service nmbd restart

Troubleshooting: No shares visible on the remote PC
Basically, if you have made changes to the configuration file "/etc/samba/smb.conf", then you should also check this with "testparm".
testparm -v

The option "-v" causes the default settings to be displayed as well.

Unless an error has been returned, the Samba services must be restarted or the configuration file re-read.
sudo service smbd restart
sudo service nmbd restart

Note: Restarting the Samba services stops any connections to the directory shares. With a reload, the connections would remain and only the configuration would be rewritten.

If the test of the configuration file with "testparm" was successful and you have not forgotten the restart of the Samba server or the reload of the configuration, there should actually be no problems with the Samba shares.

Assuming you have a working network connection on both sides, you should clarify if the Samba services are really up and running.
sudo service smbd status
sudo service nmbd status

ps ax | grep. * mbd

The list should contain "nmbd" and "smbd".

In addition, we can check with "netstat" whether the Samba ports (137 / udp, 138 / udp, 139 / tcp and 445 / tcp) are bound to the services.
sudo netstat -tulpn | grep mbd

When the Samba services are running and listening for the right ports, then nothing ever went wrong with the installation. Otherwise you have to try to get the services "smbd" and "nmbd" up and running.

If the Samba services are running but the shares are still not visible, troubleshooting will help tremendously if the Samba client is also installed on the server.
sudo apt-get install smbclient

By specifying the host or computer name, you can check whether the Samba server can be reached. However, only the host name is resolved to the IP address.
nmblookup raspberrypi

The same also works with the specification of the workgroup or the parameter "workgroup" from the global settings of the configuration file. "raspberrypi" in this case is the hostname of the Raspberry Pi.
nmblookup workgroup

It is really interesting to see which shares the Samba server provides. "raspberrypi" in this case is the host name of the Raspberry Pi. You can also use the IP address.
smbclient -N -L raspberrypi

Here the releases should be listed. If not, then you should check with "testparm" the configuration. Or perform the forgotten restart of the Samba server so that the configuration can be adopted.

Now we go one step further and check if a user login is possible. The user in this case is "pi".
smbclient -U pi -L raspberrypi

The command line will probably ask for a password. This is the password that the user got "pi" in the Samba user administration. Not the local user and not the local user on the Samba system, but really the Samba user.

Troubleshooting: User authentication failed
For authentication, the user management is provided on the server. However, Samba uses only the configured usernames and not the passwords. Therefore, a separate password must be set up with "smbpasswd".

Show all Samba users:
pdbedit -L -w

There the appropriate user who wants to access a Samba share should be created there.

If the Samba user exists, then you should look into the comparatively confusing issue of
pdbedit -L -v

see if the field "Password last set" is empty. If this is the case, set a password via "smbpasswd".
sudo smbpasswd -a pi

After entering the password you have to enter it a second time to check it. Then you should be able to access the share.

Note: There is some indication that the Samba version used on Raspbian Jessie does not always work with Windows 7. There are always problems with the registration.

Temporarily you can also use the instruction "guest = ok" in the section "[global]" in the central
configuration file "/etc/samba/smb.conf" to ensure that no password is requested when connecting.

Troubleshooting: No file and directory permissions
Most issues have rarely been related to the configuration of the Samba server, but to the set file and directory permissions. The correct setting of file and directory permissions is extremely important.
It should be noted that the file permissions in the Samba system itself must also allow the appropriate access. The Samba rights (configuration) can not cancel the system rights.

Please refer to the examples of Samba shares for directories.
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.

mount an NFS directory with autofs

Automatically mount / unmount an NFS directory with "autofs"

The goal is to make an NFS-exported directory permanently available on a client. Normally this would be done by modifying the file "/ etc / fstab" so that the NFS directory is automatically included at system startup. However, "fstab" has the disadvantage that mounting fails if no network is available at system startup. Usually you create a script that hangs the directory only when a network connection was detected. Or you can enter the mount command in the file "/etc/rc.local".

Set up NFS server on Raspberry Pi

Set up Raspberry Pi NFS server 
NFS is the abbreviation of "Network File System". This is a service that releases or exports directories on a file server to other computers over the network. Other servers or clients can mount these directories. That is, hook in their file system. Including a directory exported by an NFS server on a local client looks to the user as if that directory is on his local machine.

Raspberry Pi as a MySQL backup server

Raspberry Pi as a MySQL backup server for webhosting database
Raspberry Pi MySQL backup server

If you run a website with a MySQL database at a classic web host, then you have the problem that you can not make a decent backup here. You can do that manually with phpMyAdmin or similar tools. But unfortunately, you have to do it manually. There are also tools that do it fully automatically. But then the backup is still on the server of the web hoster. It would be better, you could pull the backup fully automatically on a separate computer.

Set up lighttpd web server on Raspberry Pi

Set up web server lighttpd on Raspberry Pi
apt-get install lighttpd

There are several web servers for the Raspberry Pi. The easiest way is with the "lighttpd". Here you have to least configure and the installation is effectively done with a command on the command line.
  • Install the web server "lighttpd".
  • Check the availability of the web server over the local network.
  • Create a new HTML page and make it available through a web server.

Set up Raspberry Pi as a WLAN bridge (WLAN access point)

Set up Raspberry Pi as a WLAN bridge (WLAN access point)
WLAN access point
Typically, WLAN routers for Internet access are also WLAN access points. In such cases, the access point has a DHCP and DNS server. So you configure your own IP network. But if you already have a DHCP and DNS server in the local network, the operation of an additional wireless router does not make much sense. Especially because the cascading of routers unnecessarily creates difficulties. This usually manifests itself with connection problems.