Quantcast
Channel: Obihoernchen's Blog » NTFS
Viewing all articles
Browse latest Browse all 2

Setup Samba 4 on Arch Linux

0
0

Note: Check this article if you want to install arch on your pogoplug.

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.

pacman -Sy samba

There is one difference to Samba 3.
The services are called smb.service and nmb.service instead of smbd.service and nmbd.service.

systemctl enable smb nmb

 

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

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.

useradd -m -g samba -s /sbin/nologin fabian

To use this user in samba shares you have to add it to samba

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

nano /etc/samba/smb.conf

Here is an example configuration.
You have to edit the Share definitions below so it fits your setup.

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

   # Some Tuning (See Optimize Performance)
   socket options = IPTOS_LOWDELAY TCP_NODELAY SO_KEEPALIVE
   write cache size = 2097152
   use sendfile = true
   getwd cache = yes

   # Global security
   public = yes

#============================ Share Definitions ==============================

# Public, read only
[Videos]
        comment = Videos for all
        read only = 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
        guest ok = 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.

socket options = IPTOS_LOWDELAY TCP_NODELAY SO_KEEPALIVE

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

use sendfile

If this parameter is yes, and the sendfile() system call is supported by the underlying operating system, then some SMB read calls (mainly ReadAndX and ReadRaw) will use the more efficient sendfile system call for files that are exclusively oplocked. This may make more efficient use of the system CPU’s and cause Samba to be faster. Samba automatically turns this off for clients that use protocol levels lower than NT LM 0.12 and when it detects a client is Windows 9x (using sendfile from Linux will cause these clients to fail).

Default: use sendfile = false

Some example values are:

write cache size = 2097152
use sendfile = true

(2097152 = 2MB – you should test some values it’s pretty memory intensive)

Don’t forget to start the samba services or reboot:

systemctl start smb nmb

Viewing all articles
Browse latest Browse all 2

Latest Images

Trending Articles





Latest Images