Template:I18n links start Template:I18n entry Template:I18n entry Template:I18n entry Template:I18n entry Template:I18n entry Template:I18n entry Template:I18n entry Template:I18n entry Template:I18n entry Template:I18n entry Template:I18n entry Template:I18n links end
Samba is a re-implementation of the SMB/CIFS networking protocol, it facilitates file and printer sharing between Linux and Windows systems or Linux-to-Linux systems as an alternative to Nfs. Samba is easily configured and operation is very straight-forward.
- 1 Installation
- 2 Configuration
- 3 Accessing Samba shares
- 4 Tips and tricks
- 5 Troubleshooting
- 6 See also
- 7 More resources
Installing only the client program is sufficient for systems that are not meant to share files, only access them:
# pacman -S smbclient
In order to make shares available to clients, install the Samba server package:
# pacman -S samba
A daemon is installed with the server and it must be started for Samba to begin working. Samba typically uses FAM to monitor the file-system for changes, yet Gamin has almost completely replaced FAM as of recent, mainly because the latter is poorly maintained and generally an inferior, unpopular choice.
To install Gamin:
# pacman -S gamin
The Samba/etc/samba/smb.conf file must be created before starting the server.
As root, copy the default Samba configuration file to Template:Filename:
# cp /etc/samba/smb.conf.default /etc/samba/smb.conf
Open Template:Filename and edit it to suit your needs. The default file creates a share for each user's home directory. It also creates a share for printers.
Starting and automating the daemons
Without rebooting, FAM and Samba can be started with the commands:
# /etc/rc.d/fam start # /etc/rc.d/samba start
SWAT: Samba web administration tool
There are many and varied opinions regarding the usefulness of SWAT. No matter how hard one tries to produce the perfect configuration tool, it remains an object of personal taste. However, SWAT is a very useful tool that allows Web-based configuration of Samba. It has a wizard that may help to get Samba configured quickly, it has context-sensitive help on each Template:Filename parameter, it provides for monitoring of current state of connection information, and it allows network-wide MS Windows network password management.
To use SWAT, first install xinetd:
# pacman -Sy xinetd
Additionally, edit Template:Filename if remote administration is needed.
The web interface can be accessed on port 901 by default,
To log into a Samba share you'll need to add a user:
# smbpasswd -a <user>
The user must already have a account on the server. If the user does not exist you will receive the error:
Failed to modify password entry for user "<user>"
You can add a new user to the Linux host with adduser. This article does not cover adding users to Windows systems.
KDE and Gnome have the ability to browse Samba shares. You therefore do not need any additional packages if using either of these DEs. If however you plan to use the share solely from a shell, you will need an additional package.
From a Nautilus/Dolphin/Konqueror window, hit Template:Keypress+Template:Keypress or go to the "Go" menu and select "Location..." -- both actions will allow you to type in the "Go to:" blank. Enter Template:Codeline and press enter.
For a GUI in the KDE System Settings you have to install the kdenetwork-filesharing package from [extra].
There are several alternatives for easy share browsing.
1. Install Template:Package Official:
# pacman -S smbnetfs
2. Add the following line to Template:Filename:
3. Load the Template:Codeline kernel module:
# modprobe fuse
# /etc/rc.d/smbnetfs start
All shares in the network are now automatically mounted under Template:Filename.
Add the following to Template:Filename to access the shares at boot:
MODULES=(... fuse ...) DAEMONS=(... smbnetfs ...)
$ yaourt -S fusesmb
2. Create a mount point:
# mkdir /mnt/fusesmb
3. Load Template:Codeline module:
# modprobe fuse
4. Mount the shares:
# fusesmb -o allow_other /mnt/fusesmb
MODULES=(... fuse ...)
Autofs is a kernel-based automounter for Linux.
1. Use smbclient to browse shares from the shell. To list any public shares on a server:
$ smbclient -L <hostname> -U%
2. Create the mount point for the share:
# mkdir /mnt/MOUNTPOINT
# mount -t cifs //SERVER/SHARENAME MOUNTPOINT -o user=USERNAME,password=PASSWORD,workgroup=WORKGROUP,ip=SERVERIP
- The Windows system's name
- The shared directory
- The local directory where the share will be mounted to
- Specifies options for Template:Codeline
4. To unmount the share, use:
# umount /mnt/MOUNTPOINT
Add the following to Template:Filename for easy mounting:
//SERVER/SHARENAME /mnt/MOUNTPOINT cifs noauto,noatime,username=USER,password=PASSWORD,workgroup=WORKGROUP 0 0
After adding the previous line, the syntax to mount files becomes simpler:
# mount /mnt/MOUNTPOINT
If adding a Samba share to Template:Filename, the Template:Codeline daemon should also be added to Template:Filename, somewhere after the network daemon. The Template:Codeline daemon will mount network partitions at boot and, more importantly, unmount network partitions at shutdown. Even if using the Template:Codeline option in Template:Filename, the Template:Codeline daemon should be used. Without it any network share that is mounted when shutting down will cause the Template:Codeline daemon to wait for the connection to time out, considerably extending poweroff time.
Allowing users to mount
//SERVER/SHARENAME /path/to/SHAREMOUNT cifs users,noauto,noatime,username=USER,password=PASSWORD,workgroup=WORKGROUP 0 0
This will allow users to mount it aslong as the mount point resides in a directory controllable by the user; i.e. the user's home. For users to be allowed to mount and unmount the Samba shares with mount points that they do not own, use #smbnetfs, or grant privileges using sudo.
Tips and tricks
Edit Template:Filename and change the following line:
security = user
security = share
If you want to restrict the shares data to a specific interface replace:
; interfaces = 192.168.12.2/24 192.168.13.2/24
interfaces = lo eth0 bind interfaces only = true
(changing eth0 to the local network you want share with.)
If you want to edit the account that access the shares, edit the following line:
; guest account = nobody
The last step is to create share directory (for write access make writable = yes):
[Public Share] path = /path/to/public/share available = yes browsable = yes public = yes writable = no
Sample configuration file
The configuration that worked for one user:
[global] workgroup = WORKGROUP server string = Samba Server netbios name = PC_NAME security = share ; the line below is important! If you have permission issues make sure the user here is the same as the user of the folder you want to share guest account = mark username map = /etc/samba/smbusers name resolve order = hosts wins bcast wins support = no
[public] comment = Public Share path = /path/to/public/share available = yes browsable = yes public = yes writable = no
If nothing is known about other systems on the local network, and automated tools such as #smbnetfs are not available, the following methods allow one to manually probe for Samba shares.
# pacman -S nmap smbclient
2. Template:Codeline checks which ports are open:
# nmap -sT 192.168.1.*
In this case, a scan on the 192.168.1.* IP address range has been performed, resulting in: Template:Command
The first result is another system; the second happens to be the client from where this scan was performed.
Regardless of the output, look for <20>, which shows the host with open services.
This shows which folders are shared and can be mounted locally. See: #Accessing Samba shares
[global] # lanman fix client lanman auth = yes client ntlmv2 auth = no
Getting a dialog box up takes a long time
I had a problem that it took ~30 seconds to get a password dialog box up when trying to connect from both Windows XP/Windows 7. Analyzing the error.log on the server I saw:
[2009/11/11 06:20:12, 0] printing/print_cups.c:cups_connect(103) Unable to connect to CUPS server localhost:631 - Interrupted system call
I don't have any printer connected to this server, so I added this to the global section:
load printers = no printing = bsd disable spoolss = yes printcap name = /dev/null
Not sure if all of them are necessary, but at least it works now.
Changes in Samba version 3.4.0
Major enhancements in Samba 3.4.0 include:
The default passdb backend has been changed to 'tdbsam'! That breaks existing setups using the 'smbpasswd' backend without explicit declaration!
If you would like to stick to the 'smbpasswd' backend try changing this in Template:Filename:
passdb backend = smbpasswd
or convert your smbpasswd entries using:
sudo pdbedit -i smbpasswd -e tdbsam
Error: Value too large for defined data type
With some applications you could get this error whith every attempt to open a file mounted in smbfs/cifs:
Value too large for defined data type
The solution is to add this options to your smbfs/cifs mount options (in /etc/fstab for example):
It works on Arch Linux up-to-date (2009-12-02)