This is Gentoo's testing wiki. It is a non-operational environment and its textual content is outdated.
Please visit our production wiki at https://wiki.gentoo.org
Samba
Samba is a re-implementation of the SMB/CIFS networking protocol, a Microsoft Windows alternative to Network File System (NFS).
Installation
Kernel
File Systems ---> [*] Network File Systems ---> [*] CIFS support (advanced network filesystem, SMBFS successor)---> [*] CIFS Statistics [*] Extended Statistics [*] CIFS Extended Attributes [*] CIFS POSIX Extentions [*] SMB2 and SMB3 network file system support
If a share fails to mount with the error
CIFS VFS: Unknown vers= option specified: 2.1
, enable the CONFIG_CIFS_SMB2 kernel option.Samba
USE flags
USE flags for net-fs/samba Samba Suite Version 4
+regedit
|
Enable support for regedit command-line tool |
+system-mitkrb5
|
Use app-crypt/mit-krb5 instead of app-crypt/heimdal. |
acl
|
Add support for Access Control Lists |
addc
|
Enable Active Directory Domain Controller support |
ads
|
Enable Active Directory support |
ceph
|
Enable support for Ceph distributed filesystem via sys-cluster/ceph |
client
|
Enables the client part |
cluster
|
Enable support for clustering |
cups
|
Add support for CUPS (Common Unix Printing System) |
debug
|
Enable extra debug codepaths, like asserts and extra output. If you want to get meaningful backtraces see https://wiki.gentoo.org/wiki/Project:Quality_Assurance/Backtraces |
fam
|
Enable FAM (File Alteration Monitor) support |
glusterfs
|
Enable support for Glusterfs filesystem via sys-cluster/glusterfs |
gpg
|
Use app-crypt/gpgme for AD DC |
iprint
|
Enabling iPrint technology by Novell |
json
|
Enable json audit support through dev-libs/jansson |
ldap
|
Add LDAP support (Lightweight Directory Access Protocol) |
llvm-libunwind
|
Use llvm-runtimes/libunwind instead of sys-libs/libunwind |
lmdb
|
Enable LMDB backend for bundled ldb |
pam
|
Add support for PAM (Pluggable Authentication Modules) - DANGEROUS to arbitrarily flip |
profiling-data
|
Enables support for collecting profiling data |
python
|
Add optional support/bindings for the Python language |
quota
|
Enables support for user quotas |
selinux
|
!!internal use only!! Security Enhanced Linux support, this must be set by the selinux profile or breakage will occur |
snapper
|
Enable vfs_snapper module (requires sys-apps/dbus) |
spotlight
|
Enable support for spotlight backend |
syslog
|
Enable support for syslog |
system-heimdal
|
Use app-crypt/heimdal instead of bundled heimdal. |
systemd
|
Enable use of systemd-specific libraries and features like socket activation or session tracking |
test
|
Enable dependencies and/or preparations necessary to run tests (usually controlled by FEATURES=test but can be toggled independently) |
unwind
|
Enable libunwind usage for backtraces |
winbind
|
Enables support for the winbind auth daemon |
zeroconf
|
Support for DNS Service Discovery (DNS-SD) |
Emerge
Install Samba:
root #
emerge --ask --noreplace net-fs/samba
Samba can also be installed by setting the global USE flag samba
and updating the system:
root #
emerge --ask --changed-use --deep @world
CIFS
USE flags
If the full Samba package is not needed, the net-fs/cifs-utils package is available:
USE flags for net-fs/cifs-utils Tools for Managing Linux CIFS Client Filesystems
+acl
|
Add support for Access Control Lists |
+ads
|
Enable Active Directory support and create cifs.idmap binary - idmap support |
+caps
|
Enable sys-libs/libcap-ng support |
+python
|
Enable support for python and install python tools |
creds
|
cifs credentials support |
pam
|
Add support for PAM (Pluggable Authentication Modules) - DANGEROUS to arbitrarily flip |
systemd
|
Enable use of systemd-specific libraries and features like socket activation or session tracking |
Emerge
Emerge the CIFS user-space tools:
root #
emerge --ask net-fs/cifs-utils
Usage
Services
OpenRC
When using OpenRC, adding Samba to the default runlevel will enable the Samba service to start when the system boots:
root #
rc-update add samba default
To start the Samba service now issue:
root #
eselect rc start samba
Systemd
For systemd users, the Samba service can be configuired to start during boot using systemctl:
root #
systemctl enable smbd.service
To start the service immediately issue:
root #
systemctl start smbd.service
Once the client is fully configured, the shares can soon be accessed.
Create the mount point:
root #
mkdir -p /mnt/My-Disk/{Media,Shared}
Mount the exported folders:
root #
mount.cifs //O2-Foobar/Media /mnt/My-Disk/Media -o guest
root #
mount.cifs //O2-Foobar/Shared /mnt/My-Disk/Shared -o guest
To automatically mount shares on every boot, edit /etc/fstab to look like this:
/etc/fstab
//O2-Foobar/Media /mnt/My-Disk/Media cifs guest //O2-Foobar/Shared /mnt/My-Disk/Shared cifs guest
- In the case of permission problems are encountered when trying to create files and folders on the disk, try to use
gid=<user's_gid>, uid=<user's_uid>
- Be sure to replace
<user's_gid>
with the user ID of choice.
Troubleshooting
Some problems may occur when trying to mount new CIFS shares. The following sections attempt to provide resolutions to common problems.
Cannot resolve <server-name>
More specifically, the actual error:
root #
mount.cifs ...
"mount error: could not find target server. TCP name foo/bar not found. No ip address specified and hostname not found"
This can easily be fixed by editing /etc/nsswitch and appending wins
next to the hosts
entry:
/etc/nsswitch
hosts: files dns wins
If this does not work, use the CIFS server's IP address instead of the O2-Foobar hostname. The nmblookup utility (provided by net-fs/samba) comes in handy when trying to find the IP address of an CIFS host:
root #
nmblookup O2-Foobar
If the system shutdown hangs at
* Unmounting network filesystems ...
then users must make sure the CIFS shares are unmounted properly before udev tries to stop. One way to work around this is to create local.d scripts to unmount the CIFS filesystems:
root #
echo "umount -a -t cifs -f" > /etc/local.d/cifs.stop
root #
chmod a+x /etc/local.d/cifs.stop
If Samba does not start after upgrading to Samba 4.2.11 with the following error:
../lib/param/loadparm.c:1082(lp_set_enum_parm) WARNING: Ignoring invalid value 'share' for parameter 'security' ../source3/smbd/server.c:1256(main) error opening config file '/etc/samba/smb.conf'
Change the Samba security parameter from share
to user
:
/etc/samba/smb.conf
[global] security = user
If guest access is enabled and the client is requesting the share username/password, set the map to guest parameter to bad user
:
/etc/samba/smb.conf
[global] map to guest = bad user
Emerge wants to downgrade to Samba 3 because of FFmpeg dependency
This is probably caused by enabling abi_x86_32
on media-video/ffmpeg, which isn't supported on Samba 4. Since Samba support is rarely needed by media-video/ffmpeg (in the typical use case, the media player itself handles media files served over smb), the samba
USE flag can be disabled for media-video/ffmpeg without losing essential functionality.
See also
- Samba (Security Handbook) - The Security Handbook's entry on how to secure a system running Samba.
- Samba 3 migration to Samba 4 guide - A well written guide on migrating a server from Samba 3 PDC to Samba 4 AD.
- Smbnetfs
- SSHFS