12

I have a machine running Ubuntu Server 12.04. I installed Samba for file sharing on my home network. I have Windows and Linux machine.

My server spec are:

  • AMD Phenom 2 x6 1055t
  • 8GB of RAM
  • 10/100/1000 ethernet

I get like 6Mbs/sec read and write.

I just installed Linux on my server, before I had Windows Server 2008 and the speed was more like 50 or 60mbps/sec.

Any idea on what would be the cause?

Here is my smb.conf config:

#======================= Global Settings =======================

[global]

## Browsing/Identification ###

# Change this to the workgroup/NT-domain name your Samba server will part of
   workgroup = WORKGROUP

# server string is the equivalent of the NT Description field
   server string = %h server (Samba, Ubuntu)

# Windows Internet Name Serving Support Section:
# WINS Support - Tells the NMBD component of Samba to enable its WINS Server
#   wins support = no

# WINS Server - Tells the NMBD components of Samba to be a WINS Client
# Note: Samba can be either a WINS Server, or a WINS Client, but NOT both
;   wins server = w.x.y.z

# This will prevent nmbd to search for NetBIOS names through DNS.
   dns proxy = no

# What naming service and in what order should we use to resolve host names
# to IP addresses
;   name resolve order = lmhosts host wins bcast

#### Networking ####

# The specific set of interfaces / networks to bind to
# This can be either the interface name or an IP address/netmask;
# interface names are normally preferred
;   interfaces = 127.0.0.0/8 eth0

# Only bind to the named interfaces and/or networks; you must use the
# 'interfaces' option above to use this.
# It is recommended that you enable this feature if your Samba machine is
# not protected by a firewall or is a firewall itself.  However, this
# option cannot handle dynamic or non-broadcast interfaces correctly.
;   bind interfaces only = yes



#### Debugging/Accounting ####

# This tells Samba to use a separate log file for each machine
# that connects
   log file = /var/log/samba/log.%m

# Cap the size of the individual log files (in KiB).
   max log size = 1000

# If you want Samba to only log through syslog then set the following
# parameter to 'yes'.
#   syslog only = no

# Do something sensible when Samba crashes: mail the admin a backtrace
   panic action = /usr/share/samba/panic-action %d


####### Authentication #######

# "security = user" is always a good idea. This will require a Unix account
# in this server for every user accessing the server. See
# /usr/share/doc/samba-doc/htmldocs/Samba3-HOWTO/ServerType.html
# in the samba-doc package for details.
   security = user

# You may wish to use password encryption.  See the section on
# 'encrypt passwords' in the smb.conf(5) manpage before enabling.
   encrypt passwords = true

# If you are using encrypted passwords, Samba will need to know what
# password database type you are using.
   passdb backend = tdbsam

   obey pam restrictions = yes

# This boolean parameter controls whether Samba attempts to sync the Unix
# password with the SMB password when the encrypted SMB password in the
# passdb is changed.
   unix password sync = yes

# For Unix password sync to work on a Debian GNU/Linux system, the following
# parameters must be set (thanks to Ian Kahan <<kahan@informatik.tu-muenchen.de> for
# sending the correct chat script for the passwd program in Debian Sarge).
   passwd program = /usr/bin/passwd %u
   passwd chat = *Enter\snew\s*\spassword:* %n\n *Retype\snew\s*\spassword:* %n\n *password\supdated\ssuccessfully* .

# This boolean controls whether PAM will be used for password changes
# when requested by an SMB client instead of the program listed in
# 'passwd program'. The default is 'no'.
   pam password change = yes

# This option controls how unsuccessful authentication attempts are mapped
# to anonymous connections
   map to guest = bad user

########## Domains ###########

# Is this machine able to authenticate users. Both PDC and BDC
# must have this setting enabled. If you are the BDC you must
# change the 'domain master' setting to no
#
;   domain logons = yes
#
# The following setting only takes effect if 'domain logons' is set
# It specifies the location of the user's profile directory
# from the client point of view)
# The following required a [profiles] share to be setup on the
# samba server (see below)
;   logon path = \\%N\profiles\%U
# Another common choice is storing the profile in the user's home directory
# (this is Samba's default)
#   logon path = \\%N\%U\profile

# The following setting only takes effect if 'domain logons' is set
# It specifies the location of a user's home directory (from the client
# point of view)
;   logon drive = H:
#   logon home = \\%N\%U

# The following setting only takes effect if 'domain logons' is set
# It specifies the script to run during logon. The script must be stored
# in the [netlogon] share
# NOTE: Must be store in 'DOS' file format convention
;   logon script = logon.cmd

# This allows Unix users to be created on the domain controller via the SAMR
# RPC pipe.  The example command creates a user account with a disabled Unix
# password; please adapt to your needs
; add user script = /usr/sbin/adduser --quiet --disabled-password --gecos "" %u

# This allows machine accounts to be created on the domain controller via the
# SAMR RPC pipe.
# The following assumes a "machines" group exists on the system
; add machine script  = /usr/sbin/useradd -g machines -c "%u machine account" -d /var/lib/samba -s /bin/false %u

# This allows Unix groups to be created on the domain controller via the SAMR
# RPC pipe.
; add group script = /usr/sbin/addgroup --force-badname %g

########## Printing ##########

# If you want to automatically load your printer list rather
# than setting them up individually then you'll need this
#   load printers = yes

# lpr(ng) printing. You may wish to override the location of the
# printcap file
#;   printing = bsd
#;   printcap name = /etc/printcap

# CUPS printing.  See also the cupsaddsmb(8) manpage in the
# cupsys-client package.
#;   printing = cups
#;   printcap name = cups

############ Misc ############

# Using the following line enables you to customise your configuration
# on a per machine basis. The %m gets replaced with the netbios name
# of the machine that is connecting
;   include = /home/samba/etc/smb.conf.%m

# Most people will find that this option gives better performance.
# See smb.conf(5) and /usr/share/doc/samba-doc/htmldocs/Samba3-HOWTO/speed.html
# for details
# You may want to add the following on a Linux system:
#         SO_RCVBUF=8192 SO_SNDBUF=8192
#   socket options = TCP_NODELAY

# The following parameter is useful only if you have the linpopup package
# installed. The samba maintainer and the linpopup maintainer are
# working to ease installation and configuration of linpopup and samba.
;   message command = /bin/sh -c '/usr/bin/linpopup "%f" "%m" %s; rm %s' &

# Domain Master specifies Samba to be the Domain Master Browser. If this
# machine will be configured as a BDC (a secondary logon server), you
# must set this to 'no'; otherwise, the default behavior is recommended.
#   domain master = auto

# Some defaults for winbind (make sure you're not using the ranges
# for something else.)
;   idmap uid = 10000-20000
;   idmap gid = 10000-20000
;   template shell = /bin/bash

# The following was the default behaviour in sarge,
# but samba upstream reverted the default because it might induce
# performance issues in large organizations.
# See Debian bug #368251 for some of the consequences of *not*
# having this setting and smb.conf(5) for details.
;   winbind enum groups = yes
;   winbind enum users = yes

# Setup usershare options to enable non-root users to share folders
# with the net usershare command.

# Maximum number of usershare. 0 (default) means that usershare is disabled.
;   usershare max shares = 100

# Allow users who've been granted usershare privileges to create
# public shares, not just authenticated ones
   usershare allow guests = yes

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

# Un-comment the following (and tweak the other settings below to suit)
# to enable the default home directory shares. This will share each
# user's home director as \\server\username
;[homes]
;   comment = Home Directories
;   browseable = no

# By default, the home directories are exported read-only. Change the
# next parameter to 'no' if you want to be able to write to them.
;   read only = yes

# File creation mask is set to 0700 for security reasons. If you want to
# create files with group=rw permissions, set next parameter to 0775.
;   create mask = 0700

# Directory creation mask is set to 0700 for security reasons. If you want to
# create dirs. with group=rw permissions, set next parameter to 0775.
;   directory mask = 0700

# By default, \\server\username shares can be connected to by anyone
# with access to the samba server. Un-comment the following parameter
# to make sure that only "username" can connect to \\server\username
# The following parameter makes sure that only "username" can connect
#
# This might need tweaking when using external authentication schemes
;   valid users = %S

# Un-comment the following and create the netlogon directory for Domain Logons
# (you need to configure Samba to act as a domain controller too.)
;[netlogon]
;   comment = Network Logon Service
;   path = /home/samba/netlogon
;   guest ok = yes
;   read only = yes

# Un-comment the following and create the profiles directory to store
# users profiles (see the "logon path" option above)
# (you need to configure Samba to act as a domain controller too.)
# The path below should be writable by all users so that their
# profile directory may be created the first time they log on
;[profiles]
;   comment = Users profiles
;   path = /home/samba/profiles
;   guest ok = no
;   browseable = no
;   create mask = 0600
;   directory mask = 0700

#[printers]
#   comment = All Printers
#   browseable = no
#   path = /var/spool/samba
#   printable = yes
#   guest ok = no
#   read only = yes
#   create mask = 0700

# Windows clients look for this share name as a source of downloadable
# printer drivers
#[print$]
#   comment = Printer Drivers
#   path = /var/lib/samba/printers
#   browseable = yes
#   read only = yes
#   guest ok = no
# Uncomment to allow remote administration of Windows print drivers.
# You may need to replace 'lpadmin' with the name of the group your
# admin users are members of.
# Please note that you also need to set appropriate Unix permissions
# to the drivers directory for these users to have write rights in it
;   write list = root, @lpadmin

 A sample share for sharing your CD-ROM with others.
[media]
   read raw = no
   comment = Samba server's Media
   read only = no
   browsable = yes
   path = /mnt/media
   guest ok = yes
   create mask = 0755

[test]
   read raw = no
   comment = test
   read only = no
   browsable = yes
   path = /mnt/test
   guest ok = yes
   create mask = 0755

# The next two parameters show how to auto-mount a CD-ROM when the
#       cdrom share is accesed. For this to work /etc/fstab must contain
#       an entry like this:
#
#       /dev/scd0   /cdrom  iso9660 defaults,noauto,ro,user   0 0
#
# The CD-ROM gets unmounted automatically after the connection to the
#
# If you don't want to use auto-mounting/unmounting make sure the CD
#       is mounted on /cdrom
#
;   preexec = /bin/mount /cdrom
;   postexec = /bin/umount /cdrom
6
  • 1
    Could you check that you are really using a fast ethernet line? Just look at the line: Speed:... int he output of ethtool eth0. Feb 6, 2014 at 16:46
  • 1
    Thanks for the fast reply,I checked and it is really 1000Mb/sec
    – reeves
    Feb 6, 2014 at 17:00
  • Please explain your setup. Are you writing from a windows machine to the Linux server? How are you connecting? Is this over samba? Do you have the same problems if you use a linux machine to connect to he samba share?
    – terdon
    Feb 6, 2014 at 17:08
  • I'm connecting via ssh from a ubuntu machine, speed is the same in windows and ubuntu.
    – reeves
    Feb 6, 2014 at 17:27
  • So what does samba have to do with it if you're connecting with ssh? Also, when posting configuration files, tell us what file you're posting. I assume that's /etc/samba/smb.conf but there are other possibilities.
    – terdon
    Feb 6, 2014 at 19:07

6 Answers 6

10

It is of course difficult to diagnose a system with no information like this. The best I can do is to suggest this Web page in the samba.org site, entitled Samba performance tuning, where a number of performance tweaks are suggested.

It appears the most critical one if the presence of the option:

 socket options = TCP_NODELAY

in the socket option section of the smb.conf file (/etc/samba/smb.conf).

Another option that degrades samba performance is the verbosity level in the log operations. The log level should be kept at 2 at most.

The Web page above has several other suggestions, to be tried in turn, I guess, including a very strange story about a printer atrociously slowing down samba transfers (at the vry end, in the section Samba Performance is Very Slow). It is obviously a cautionary tale.

4
  • Thank you for your help, I tried this socket option with no change. I commented all print option cause i dont use it. I'll read that page and try all option to see what's the problem.
    – reeves
    Feb 6, 2014 at 17:50
  • Just For Info, adding this option still increases the speed.
    – AB Abhi
    Oct 21, 2021 at 18:35
  • wiki.samba.org/index.php/Performance_Tuning recommends NOT to set this option.
    – jan-glx
    Jan 20 at 10:52
  • Not true: no mention of TCP_NODELAY on wiki.samba.org/index.php/…. Jan 21 at 11:12
10

I had the same problem. My solution was:

read raw = Yes
write raw = Yes
socket options = TCP_NODELAY IPTOS_LOWDELAY SO_RCVBUF=131072 SO_SNDBUF=131072
min receivefile size = 16384
use sendfile = true
aio read size = 16384
aio write size = 16384
7
  • 1
    Thanks for the answer! Could you explain which parameters actually affect performance? And is it possible to use even higher values and get even more speed? Jun 15, 2015 at 13:21
  • @DmitryGrigoryev Can see them all here: samba.org/samba/docs/man/Samba-HOWTO-Collection/speed.html, note read raw is turned on by default but may actually degrade perf..
    – markmnl
    Sep 26, 2016 at 23:55
  • 3
    The comment above, and the content in the answer above appears to be dated and no longer correct.
    – Warren P
    Apr 2, 2019 at 19:23
  • Adding only the socket options changed the transfer speed between guest system and host system from 1.5 MiB/s to 90 MiB/s for me (Qemu guest running Win 10 on an Ubuntu 18.04 host)
    – Karlsson
    Jun 5, 2019 at 7:53
  • the samba config file on my Kubuntu 20.04 has too many lines and currently there isn't any [commented] entry for socket options. If I want to add the socket options where in the file shall I add it. Feb 19, 2021 at 10:16
3

Just adding my own experience as I had a similar issue and found this thread when searching for an answer. Hopefully this might help someone.

My home server is an HP N36L originally running Windows Home Server 2011 (a cut down Windows Server 2008 R2). As that is now out of support I needed to update it but the Windows Server options were out of my price range so I installed Linux Mint Mate as a replacement and then installed XRDP for remote access and Samba for file shares.

When running Windows HS2011, file transfers to file shares had taken place at over 100MB/s but using Linux I was only getting 20MB/s which was disappointing.

Before I had upgraded the HP I did a test on an old PC at setting up Linux with Samba so I went back to this and noticed that file transfers to a Samba share were also over 100MB/s.

Finally the difference dawned on me. The old PC only had a single EXT4 formatted disc with the OS and shared folder but with my HP server I had left the 2 NTFS formatted data drives as is. So I set up a shared folder on the HP server EXT4 formatted drive as a test, and file transfers to that share were over 100MB/s.

So I suppose the lesson is Samba shares and NTFS formatted drives are not a good combination.

1
  • In general, NTFS on Linux is not a high performance filesystem. You can do basic tasks, but NTFS on Linux uses an userland driver (whereas NTFS on Windows uses a native kernel driver). Also, NTFS is a proprietary filesystem of Microsoft, that was somehow reverse engineered for Linux, but there are no official specifications available for the internal structures.
    – TFuto
    Jan 23 at 7:40
1

To expand on MariusMatutiae's answer. In addition to uncommenting the TCP_NODELAY (which allows multiple packet sending) you can include these options on the same socket line:

IPTOS_LOWDELAY SO_SNDBUF=8192 SO_RCVBUF=8192

These have various performance affects to do with packet sending which may help depending on your network setup. Doesn't hurt to include them.

2
  • 5
    The buffer size you give (8192) date back from Samba 1.x or 2.x more than a decade ago. Unfortunately these inappropriate settings keep surfacing again and again due to good old cargo-cultism :) Please use numbers at least 8 times as much (65536 or 131072 are more appropriate values nowadays).
    – wazoox
    Oct 19, 2016 at 14:00
  • Specifying buffers made my system slower.
    – Warren P
    Apr 2, 2019 at 19:24
0

Just letting you guys know the issue I faced as I had been looking for a fix and came across this article.

I have the following:

Linux VM (Debian 10.9.0) sitting on a HP laptop running ESXi 6.0. The VM is running Samba SMB File Share.

Windows 10 (Version 1809) Desktop Workstation. - MSI Z97-G45 Gaming, E2200 NIC Driver

When transferring files from the Windows 10 Workstation to the Samba share the speeds were extremely slow. From the Windows 10 workstation to another windows workstation I saw no speed issues.

It all came down to a setting in the Killer Network Manager application, under settings, make sure to untick "Enable Advanced Stream Detect" and the issue will be resolved. I have uploaded a video of what I was experiencing and the fix.

https://www.youtube.com/watch?v=fkasUA1FQ8U

Hope this helps anyone else in my situation.

-2

are you connecting via lan or wireless ?

anyway, try to update firmware on router. if not help, disable firewall:

sudo ufw disable

You can see similar problem solved here: http://ubuntuforums.org/showthread.php?t=2080387

1
  • Thanks, I tried disabling the firewall but it made no change, the firmware is already the latest.
    – reeves
    Feb 6, 2014 at 17:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.