this is obsolete doc -- see http://doc.nethence.com/ instead
Basic Samba configuration
Requirements
On Redhat systems,
rpm -q samba
service samba restart
chkconfig samba on
On NetBSD,
#export PKG_PATH=ftp://ftp.fr.netbsd.org/pub/pkgsrc/packages/NetBSD/amd64/6.1/All
pkg_add samba
cd /etc/rc.d/
cp /usr/pkg/share/examples/rc.d/winbindd .
cp /usr/pkg/share/examples/rc.d/smbd .
cp /usr/pkg/share/examples/rc.d/samba .
cp /usr/pkg/share/examples/rc.d/nmbd .
cd ../
cat >> rc.conf <<EOF9
samba=yes
smbd=yes
nmbd=yes
winbindd=yes
EOF9
rc.d/samba restart
Configuration
On NetBSD only,
cd /etc/
ln -s /usr/pkg/etc/samba
Then on any system,
cd /etc/samba/
mv smb.conf smb.conf.dist
sed '/^[[:space:]]*$/d; /^[[:space:]]*;/d; /^[[:space:]]*#/d;' smb.conf.dist > smb.conf
vi smb.conf
change,
workgroup = ...
printing = bsd
unix extensions = no
Note. printing = bsd to avoid this recurrent error (also touch /etc/printcap). "printcap name = /etc/printcap" is supposed to works too.
Unable to connect to CUPS server localhost:631 - Connection refused
Note. unix extensions no to disable symlinks and such.
If you don't want to share home directories but precise folder locations,
[data]
path = /data
valid users = USERNAME
writable = yes
printable = no
Fix the ulimit system-wide. On Redhat,
vi /etc/security/limits.conf
* - nofile 16384
or
samba soft nofile 16384
samba hard nofile 32768
on NetBSD,
echo "kern.maxfiles=30000" >> /etc/sysctl.conf
sysctl -w kern.maxfiles=30000
vi /etc/login.conf
change,
default:\
:path=/usr/bin /bin /usr/sbin /sbin /usr/X11R6/bin /usr/pkg/bin /usr/pkg/sbi
n /usr/local/bin:\
:umask=022:\
:datasize-max=3072M:\
:datasize-cur=1024M:\
:maxproc-max=1044:\
:maxproc-cur=512:\
:openfiles-cur=16384:\
:openfiles-max=16384:\
:stacksize-cur=8M:
apply,
cap_mkdb /etc/login.conf
##usermod -L default root
#echo 'start_precmd="ulimit -n 16384"' > /etc/rc.conf.d/samba
Now enter a new shell to run the new file descriptor limit and check the configuration,
ulimit -n
(netbsd) sysctl kern.maxfiles
(netbsd) sysctl proc.curproc.rlimit.descriptors
testparm
Restart the daemon to apply the changes. On Redhat systems,
service samba restart
on NetBSD,
/etc/rc.d/samba restart
Add the samba user and check (same UNIX user needs to exist, or edit smbusers),
cd /etc/samba/
cat smbpasswd
smbpasswd -a USERNAME
ls -l private/
The log file location:
- on Redhat it is /var/log/samba/log.%m
- on Slackware it is /var/log/samba.%m
- on NetBSD it is
Guest account
If you want the 'guest' account to work, create the guest user,
useradd guest
smbpasswd -a guest
note. you can also use /etc/samba/smbusers to link the samba guest user with system's nobody user.
and configure the shared folder,
cd /etc/samba/
vi smb.conf
add,
[global]
...
guest account = guest
unix extensions = no
[nas]
path = /data/nas
#valid users = username
public = yes
writable = yes
printable = no
note. 'public' is a synonym for 'guest ok'
Additionnal settings
Note. for some embedded system you may prefer not to have any logs,
;[global]
;log level = 0
Note. to secure the thing a little bit,
;[global]
;hosts allow = 10.1.1
Note. to force rights, e.g. enabling group to write,
;[data]
;create mask = 0770
;directory mask = 0770
Client usage
Check the share is available,
smbclient -W workgroup_or_domaine -U username -L SAMBA_SRV
Mount the share,
mount.cifs //samba_srv/share_name /mnt/smb -o rw,user=username,pass=password,dom=workgroup_or_domain
Note. on some systems it's mount.smbfs or smbmount instead of mount.cifs.
Note. eventually add password="PASSWORD"
Enable at system's startup,
cd /etc/
vi fstab
add,
//samba_srv/share_name /mnt/mount_point cifs rw,credentials=/etc/smb.client 0 0
configure the credentials,
cd /etc/
vi smb.client
like,
username=value
password=value
domain=value
fix the permissions,
chmod 600 smb.client
Misc
Note. smbd ports,
135 tcp
139 tcp
445 tcp
Note. nmbd ports,
137 udp
138 udp
Troublesshooting
If you get this error while doing 'textparm',
rlimit_max: rlimit_max (3404) below minimum Windows limit (16384)
then you should increase the max opened file descriptor limit. See above.
References
Chapter 19. Tuning NetBSD: http://www.netbsd.org/docs/guide/en/chap-tuning.html
tuning netbsd for performance: http://wiki.netbsd.org/tutorials/tuning_netbsd_for_performance/
Resolving samba testparm message: rlimit_max: rlimit_max (8192) below minimum Windows limit (16384): http://serverfault.com/questions/509560/resolving-samba-testparm-message-rlimit-max-rlimit-max-8192-below-minimum-wi