Important: You are required to change your passwords used for Gentoo services and set an email address for your Wiki account if you haven't done so. See the full announcement and Wiki email policy change for more information.

Samba

From Gentoo Wiki
Jump to: navigation, search
IconInformation.png
This article is a stub. You can help Gentoo Wiki by expanding it.
External resources

Samba is a re-implementation of the SMB/CIFS networking protocol, an MS Windows alternative to NFS.

Installation

Kernel

You need to activate the following kernel options:

Kernel configuration

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

Software

Samba

→ Information about USE flags
USE flag Default Recommended Description
acl No Adds support for Access Control Lists
addns No Enable AD DNS integration
ads No Enable Active Directory support
aio No 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 No 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 http://www.gentoo.org/proj/en/qa/backtraces.xml
dmapi No Enable support for DMAPI. This currently works only in combination with XFS.
doc No Adds 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 Adds LDAP support (Lightweight Directory Access Protocol)
ldb No Enable the ldb tools
netapi No Enable building of netapi bits
pam No Adds support for PAM (Pluggable Authentication Modules) - DANGEROUS to arbitrarily flip
quota No Enables support for user quotas
readline No Enables support for libreadline, a GNU line-editing library that almost everyone wants
server No Enables the server part
smbclient No 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 Enables support for syslog
winbind No Enables support for the winbind auth daemon
root # emerge --ask net-fs/samba

CIFS

If you don't really want the full samba package, you can install only the net-fs/cifs-utils package:


→ Information about USE flags
USE flag Default Recommended Description
ads No Enable Active Directory support
caps No libcap support
caps-ng No libcap-ng support
creds No cifs credentials support
root # emerge --ask cifs-utils

Usage

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

Cifs share

Mount the shared content

When your client is fully configured, you can access the shares like this:

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
Automatically mount shares on every boot

If you want to automatically mount your shares on every boot, then edit your 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
Note
In case you get permission problems when trying to create files and folders in your disk, try to use gid=<your_user_gid>, uid=<your_user_uid>.

Troubleshooting

The following problems may pop up when trying to mount your shiny new CIFS shares:

Cannot resolve <server-name>

And more specifically, the actual error looks like this

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 hosts entry

File/etc/nsswitch

hosts: files dns wins

If this does not work, you can use the NFS server's IP address instead of the O2-Foobar hostname. You can use the nmblookup utility (provided by net-fs/samba) to find out the IP address of an NFS host

root # nmblookup O2-Foobar

Shutdown process hangs when trying to unmount cifs shares

In case your system fails to shutdown or reboot properly, then you need to make sure you umount the cifs shares before udev tries to stop.

The easy way is to create a local.d script:

root # echo "umount -a -t cifs -f" > /etc/local.d/cifs.stop

Win box asking for passwords

security = share

Resources