From Gentoo Wiki
Jump to: navigation, search

Samba is a re-implementation of the SMB/CIFS networking protocol, a Microsoft Windows alternative to Network File System (NFS).



KERNEL Enabling CIFS and SMB2/SMB3 support
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.


USE flags

USE flags for net-fs/samba Samba Suite Version 4

acl Add support for Access Control Lists global
addc Enable Active Directory Domain Controller support local
addns Enable AD DNS integration local
ads Enable Active Directory support local
ceph Enable support for Ceph distributed filesystem via sys-cluster/ceph local
client Enables the client part local
cluster Enable support for clustering local
dmapi Enable support for DMAPI. This currently works only in combination with XFS. local
fam Enable FAM (File Alteration Monitor) support global
gpg Use app-crypt/gpgme for AD DC local
iprint Enabling iPrint technology by Novell local
json Enable json audit support through dev-libs/jansson local
ldap Add LDAP support (Lightweight Directory Access Protocol) global
python Add optional support/bindings for the Python language global
quota Enables support for user quotas local
syslog Enable support for syslog global
system-heimdal Use app-crypt/heimdal instead of bundled heimdal. local
system-mitkrb5 Use app-crypt/mit-krb5 instead of app-crypt/heimdal. local
winbind Enables support for the winbind auth daemon local


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


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 global
ads Enable Active Directory support and create cifs.idmap binary - idmap support local
caps libcap support local
caps-ng libcap-ng support local
creds cifs credentials support local


Emerge the CIFS user-space tools:

root #emerge --ask net-fs/cifs-utils




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


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

CIFS share

Mount the shared content

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:

FILE /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.


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:

FILE /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

Shutdown process hangs when trying to unmount CIFS shares

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

Client asking for share username/password

If Samba does not start after upgrading to Samba 4.2.11 with the following error:

WARNING: Ignoring invalid value 'share' for parameter 'security'
error opening config file '/etc/samba/smb.conf'

Change the Samba security parameter from share to user:

FILE /etc/samba/smb.conf
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:

FILE /etc/samba/smb.conf
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

External resources