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).



Activate the following kernel options:

File Systems --->
    [*] Network File Systems --->
        [*] CIFS support (advanced network filesystem, SMBFS successor)--->
            [*] CIFS Statistics
                [*] Extended Statistics
            [*] CIFS Extended Attributes
                [*] CIFS POSIX Extentions


USE flags

Optional USE flags for net-fs/samba:
USE flag (what is that?) Default Recommended Description
acl Yes Add support for Access Control Lists
addns No Enable AD DNS integration
ads No Enable Active Directory support
aio Yes Enable asynchronous IO support
avahi No Add avahi/Zeroconf support
caps No Use Linux capabilities library to control privilege
cluster No Enable support for clustering
client Yes Enables the client part
cups No Add support for CUPS (Common Unix Printing System)
debug No Enable extra debug codepaths, like asserts and extra output. If you want to get meaningful backtraces see Backtraces
dmapi No Enable support for DMAPI. This currently works only in combination with XFS.
doc No Add extra documentation (API, Javadoc, etc). It is recommended to enable per package instead of globally
examples No Install examples, usually source code
fam No Enable FAM (File Alteration Monitor) support
ldap No Add LDAP support (Lightweight Directory Access Protocol)
ldb No Enable the ldb tools
netapi Yes Enable building of netapi bits
pam Yes Add support for PAM (Pluggable Authentication Modules) - DANGEROUS to arbitrarily flip
quota No Enables support for user quotas
readline Yes Enable support for libreadline, a GNU line-editing library that almost everyone wants
server Yes Enables the server part
smbclient Yes Enable smbclient tool
smbsharemodes No Enable special smb share modes (?)
selinux No  !!internal use only!! Security Enhanced Linux support, this must be set by the selinux profile or breakage will occur
swat No Enables support for swat configuration gui
syslog No Enable support for syslog
winbind Yes Enables support for the winbind auth daemon


Emerge Samba:

root #emerge --ask net-fs/samba

You can also install net-fs/samba by setting the global USE flag samba and updating the system:

root #emerge -avtDNu world


USE flags

If the full Samba package is not needed, the net-fs/cifs-utils package is available:

Optional USE flags for net-fs/cifs-utils:
USE flag (what is that?) Default Recommended Description
acl Yes Add support for Access Control Lists
ads Yes Enable Active Directory support
caps Yes libcap support
caps-ng Yes libcap-ng support
creds No cifs credentials support


Emerge CIFS:

root #emerge --ask cifs-utils



root #rc-service samba start
root #rc-update add samba default

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 NFS 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 NFS 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

Windows asking for passwords

security = share

See also

External resources