User Tools

  • (equal to forum credentials)

Site Tools


samba

This is an old revision of the document!


Samba on XBian

From the official Samba wiki: “Samba is an Open Source / Free Software suite that has, since 1992, provided file and print services to all manner of SMB/CIFS clients, including the numerous versions of Microsoft Windows operating systems”.

Samba on XBian is installed and activated already out of the box. You can activate or deactivate Samba using “xbian-config” on the BASH command line shell via SSH(preferred) or consol: xbian-config –> Services –> samba

As Samba is not running as a traditional daemon but is started on-demand by the super-server daemon 'inetd' , that is monitoring ports TCP 139 & 445 for new client connections, you can enable or disable Samba using below BASH commands as well:

# Disable Samba:
sudo update-inetd --disable netbios-ssn
sudo update-inetd --disable microsoft-ds

# Enable Samba:
sudo update-inetd --enable netbios-ssn
sudo update-inetd --enable microsoft-ds

To see what other services are provided by inetd, like SSH for example, check the inetd config file. Dont edit this file manually but use the 'update-inetd' command instead!

less /etc/inetd.conf

XBian comes with some shares configured and active already. To access these shares from Windows, enter below UNC in explorer:

\\XBIAN_IP_ADDRESS\

To access via BASH:

# cifs-utils package required
sudo mount -t cifs -o username=guest,passwd=guest //XBIAN_IP_ADDRESS/SHARE_NAME /mnt

Shares are configured in the Samba config file ”/etc/samba/shares.conf” and can be edited using for example the 'nano' text editor:

sudo nano /etc/samba/shares.conf

To add new shares, best practice is to copy an existing share from the 'shares.conf' file, and modify to your needs. Any changes made in that 'shares.conf' file are active immediately upon save. To be sure the changes propagated properly, close all Samba connections and wait half a minute. Or check if no Samba daemons are active anymore with the “ps -e | grep smbd” command. The Samba daemons/sessions time-out after while of inactivity and close. Remember, they get started again (with new settings this time) by the inetd daemon as soon as a new client tries to connect.

Below some useful BASH commands:

# List block devices like the SD card or USB hard disk drives:
lsblk
sudo fdisk -l

# Show mounted filesystems:
mount

# Monitor Samba status (CTRL-c to exit):
sudo watch smbstatus

# Monitor number of active Samba daemons (CTRL-c to exit):
sudo watch 'ps -e | grep smbd'

# Monitor network connections on TCP ports 139 and 445 used by Samba (CTRL-c to exit):
sudo watch "netstat -natp | grep ':139 \|:445 '"

# Create a new Samba user/pass besides the 'guest' user.
# Need to be 'root' user for this one so activate 'SSH root login' in 'xbian-config' and
# use "su -" command to become root afterwards:
smbpasswd –a <SAMBA_USERNAME>

# Syntax for "valid users =" directive in 'shares.conf' can be found here:
# https://www.samba.org/samba/docs/man/manpages-3/smb.conf.5.html#VALIDUSERS
man -P "less -p '       valid users '" smb.conf

# Show global Samba configuration settings:
less /etc/samba/smb.conf

References:

samba.1433201286.txt.gz · Last modified: 2015/06/02 01:28 by deHakkelaar