Sunday, October 26, 2014

SAMBA ARCHLINUX

copy paste from :http://obihoernchen.net/wordpress/877/setup-samba-4-on-arch-linux/
for my own documentation 

Samba 4 is out now
So I’ll make this tutorial for Samba 4 because it seems to be slightly faster.
This article will tell you how to install it on your PogoplugV2 or another PlugPC.
Should be pretty much the same for all arch installations.
Samba 3 is going to be removed once Samba 4 is installed.
Your old config will be saved to /etc/samba/smb.conf.pacorig
Installation of Samba 4 is pretty easy.
1
pacman -Sy samba
Now enable the services.
1
systemctl enable smbd nmbd

Create Users

If you want to create shares for multiple users you have to create new Unix user and add this one to samba as well.
To make it clean we will create a group called “samba”.
1
groupadd samba
Now we can add a new user to this group. This user “fabian” is not able to login (-s /sbin/nologin) for security purposes.
1
useradd -m -g samba -s /sbin/nologin fabian
To use this user in samba shares you have to add it to samba
1
pdbedit -a -u fabian

Create Shares

We are ready to configure our samba shares.
At the beginning configure
To do so edit /etc/samba/smb.conf
1
nano /etc/samba/smb.conf
Here is an example configuration.
You have to edit the Share definitions below so it fits your setup.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
[global]
   workgroup = WORKGROUP
   server string = POGOPLUG
   netbios name = POGOPLUG
   # hosts allow = 192.168.0.
   printcap name = /dev/null
   load printers = no
   disable spoolss = yes
   printing = bsd
   show add printer wizard = no
   print notify backchannel = no
   log file = /var/log/samba/log.%m
   max log size = 50
   security = user
   dns proxy = no
   # For public share without login
   map to guest = Bad User
   # Android bugix for reading files (samba4 bug see: https://bugzilla.samba.org/show_bug.cgi?id=9706)
   unix extensions = false
   # Fix for file batch copy issues (see: http://archlinuxarm.org/forum/viewtopic.php?f=18&t=4864)
   oplocks = no
   level2 oplocks = no
   # Some Tuning (See Optimize Performance)
   socket options = TCP_NODELAY IPTOS_LOWDELAY SO_RCVBUF=65536 SO_SNDBUF=65536
   write cache size = 131072
   # sendfile will interrupt data transfer :/ (but cpu usage is less)
   # use sendfile = true
   getwd cache = yes
   min receivefile size = 16384
   max xmit = 65536
   # Global security
   public = yes
#============================ Share Definitions ==============================
# Public, read only
[Videos]
        comment = Videos for all
        read only = yes
        # use this only for read only shares!
        fake oplocks = yes
        path = /media/zincobi/Videos
# Public, writeable
[Abrechnungen]
        comment = Abrechnungen
        read only = no
        writeable = yes
        path = /media/zincobi/Abrechnungen
# whole HDD, only for fabian
[zincobi]
        comment = Fabians share
        public = no
        valid users = fabian
        read only = no
        writeable = yes
        path = /media/zincobi

Optimize performance

The stock performance of samba isn’t that great. Especially with NTFS.
But there are some parameters which will increase Samba performance significantly.
Add all these settings to the global section in your smb.conf file.
1
socket options = TCP_NODELAY IPTOS_LOWDELAY SO_RCVBUF=65536 SO_SNDBUF=65536
The main problem for slow file transfer speeds is NTFS, because NTFS needs much CPU on linux.
Nevertheless there are 2 options which will boost the speed:
write cache size
If this integer parameter is set to non-zero value, Samba will create an in-memory cache for each oplocked file (it does not do this for non-oplocked files). All writes that the client does not request to be flushed directly to disk will be stored in this cache if possible. The cache is flushed onto disk when a write comes in whose offset would not fit into the cache or when the file is closed by the client. Reads for the file are also served from this cache if the data is stored within it.
This cache allows Samba to batch client writes into a more efficient write size for RAID disks (i.e. writes may be tuned to be the RAID stripe size) and can improve performance on systems where the disk subsystem is a bottleneck but there is free memory for userspace programs.
The integer parameter specifies the size of this cache (per oplocked file) in bytes.
Default: write cache size = 0
Example: write cache size = 262144 # for a 256k cache size per file
Some example values are:
1
write cache size = 131072
(131072= 128KB – you should test some values it’s pretty memory intensive)
Don’t forget to start the samba services or reboot:
1
systemctl start smb nmb


No comments:

Post a Comment