# Samba Troubles, Slow connections

## Aonoa

Here's the problem: I'm trying to stream video from my samba server to my samba client, both are gentoo machines and the connection is just too slow. When a friend was visiting with his laptop (windows), my gentoo client had slow transfers from those shares as well. By slow I am talking about 10-500KB/sec, when with FTP I get 15-20MB/sec. I have a gigabit network, so that is the speed I should be getting from smb as well. I'm able to play xvids and anything smaller than a DVD, I wouldn't really care about getting the maximum speed as long as I'm able to play DVD's as well. Here is a weird thing I've encountered, if when my client tries to play a DVD through the mounted samba share I do other things (like web browsing) that puts a load on the clients ethernet interface.. samba speeds up somewhat. If I keep doing more things to load the network, like repeating a find search in the mounted samba share, the speed could briefly go all the way up to 2MB/sec. Now how weird is that?

Here's what I've tried: Two different 2.6.11 kernels as well as my current 2.6.12.6 patched with reiser4 and vesafb-tng. I can't try any earlier than 2.6.11 because I formatted my root with a 2.6.11 reiser4 enabled kernel. I've tried both "unstable" and "stable" samba, current version is the latest in portage; samba-3.0.14a-r2. I've tried everything from a very basic smb.conf to the one I have now with a lot of different options in it, none of which have helped in the least. I have both smbfs and cifs compiled as modules, both of them has the same slow speed. I've read people suggest removing the socket options, that had no effect. At some point almost everything from this config wasn't there to start with.

```
[global]

   interfaces = lo eth0 10.0.0.2/24

   workgroup = WORKGROUP

   netbios name = sir

   hosts allow = 10.0.0. 127.

   max mux = 100

   dns proxy = no

   disable netbios = yes

   local master = no

   ldap ssl = no

   server string = Samba Server %v

   log file = /var/log/samba3/log.%m

   max log size = 50

   map to guest = bad user

   security = user

   encrypt passwords = yes

   smb passwd file = /etc/samba/private/smbpasswd

   socket options = TCP_NODELAY SO_RCVBUF=8192 SO_SNDBUF=8192

   wins support = no

   load printers = no

   disable spoolss = yes

   dead time = 15

   getwd cache = yes

   wide links = no

   read raw = yes

   write raw = yes

   level2 oplocks = true

   oplocks = yes

   max xmit = 65535

[public]

   comment = Public Stuff

   path = /home/ftp

   public = yes

   case sensitive = no

   writable = yes

   browsable = yes

[ftp]

   comment = Public Stuff

   path = /opt/glftpd/site/incoming

   public = yes

   case sensitive = no

   writable = yes

   browsable = yes
```

So to sum it up, everything in my network except samba is working flawlessly. Suggestions? I've searched the forums to no avail and I seem to be loosing my morale for further fault-seeking/testing.

EDIT: This is laughable really, with a little bash script I'm looping a 'find' inside the samba mount resulting in fully working DVD streaming. Speeds go from approx. 500KB to 10MB while the script runs at the same time as a DVD is played, when there is no DVD played the script only makes up for about 10-100KB bandwidth usage. Why on earth would samba only reach speeds of 1MB++ when I put just a tiny bit more strain on the network..

EDIT: At least this proves that samba is capable of using enough bandwidth to stream DVD's. I'm still looking for better solution than my hack, of course. Any input regarding this would be appreciated, thanks.

----------

## Aonoa

Some further testing with a samba server at work revealed that my laptop got a more constant 1MB/sec transfer rate as opposed to around 100-500KB/sec at home. I've almost copied that servers smb.conf which didn't help at all, I really doubt it's a conf problem. I think it's either kernel related or maybe samba compile options or what not. The server at work was a 2.6.10 kernel. I would appreciate input from others who run samba on 2.6.12 kernels, fast?, slow? what's your experiences, do you mount with cifs or smbfs? anyone else using samba with reiser4 filesystems?

----------

## Janne Pikkarainen

 *eonic wrote:*   

> Some further testing with a samba server at work revealed that my laptop got a more constant 1MB/sec transfer rate as opposed to around 100-500KB/sec at home. I've almost copied that servers smb.conf which didn't help at all, I really doubt it's a conf problem. I think it's either kernel related or maybe samba compile options or what not. The server at work was a 2.6.10 kernel. I would appreciate input from others who run samba on 2.6.12 kernels, fast?, slow? what's your experiences, do you mount with cifs or smbfs? anyone else using samba with reiser4 filesystems?

 

I use Samba at work. The Gentoo server (with kernel 2.6.12-gentoo-r4 at the moment, though it's been running with 2.6.x from 2.6.6 or so... before that it was 2.4.x) is connected to a gigabit network and a Windows box downloads stuff from the server. Speed is around 30 megabytes per second, and the limiting factor seems to be Windows-side, it's DLT box to be more precise. I haven't altered any network related Samba settings.

----------

## Aonoa

What about a linux client connecting to that server to download stuff? same speeds, same kernel? what about your samba versions and USE flags? Something on either my client or server, maybe even both is weird.

----------

## Janne Pikkarainen

Works well in both directions.

[ebuild   R   ] net-fs/samba-3.0.14a-r2  +acl -cups -doc -kerberos -ldap -libclamav +mysql -oav +pam -postgres +python -quotas +readline (-selinux) -winbind -xml -xml2 17 kB

----------

## Aonoa

Maybe it's reiser4's fault, though I fail to see how that could have anything to do with it.. I bet you're not using reiser4 on any of those machines? Is there even anyone at all out there using samba and reiser4?

----------

## Janne Pikkarainen

I'm using ReiserFS v3. I don't know how v4 could affect Samba's performance, at least that much.

Is there some kind of router box at your home between the boxes (yes there is, I'd guess)? Maybe that is the bad guy of this story? Have you tried to connect your laptop directly to your server?

----------

## Aonoa

Server and client are on the same subnet, no routing between them. Along with that, ftp connections get speeds in the order of 10-20 megabytes per second. I could try and find a method for playing a dvd directly without mounting the samba share first, just to see if there is a difference.

----------

## Aonoa

Now I've tried using the samba server with a Windows box and it achieved speeds of up to 8 Megabytes per second. Seems like there is something wrong with both the linux client and samba server since the speed should have been around 20 Megabytes per second. This test was still done with the reiser4 filesystem on the samba server, I will try to transfer files from a different filesystem. I really can't pin the problem to anything else other than reiser4, it's the only thing that stands out.. :/ well, we'll see soon enough.

----------

## hysteresis

 *eonic wrote:*   

> . This test was still done with the reiser4 filesystem on the samba server, I will try to transfer files from a different filesystem.

 

Just how are you accessing the share? Are you using smbmount? mount?  Through a GUI or on a commandline?

What ethernet driver are you using?  Since the connection is going only one way -- from the server to the client -- there could be something wrong with the ethernet drivers.

I have encountered a problem when use the smbmount command.  My experience is that this command only works with windows shares and not from linux to linux.  The mount command seems to work better.  

```
mount -t cifs //smbserver/user /mnt/shares  -o username=user,password=passwd
```

Do NOT use -t smbfs when mounting a linux share on a linux machine.

I also found that the the there are some things you need to do in smb.conf

I have not been able to get the  mount to recognize symlinks so I turned off

```
unix extensions = no
```

This recognizes every link as a hard link.

look at your socket options.

```
socket options  =  TCP_NODELAY  SO_RCVBUF=8192 SO_SNDBUF=8192
```

You might want to increase the size of the buffers.  It maybe that  the acknowledgements from the client side are slowing things down. .  Also, set

```
oplocks = true

Read size =16384
```

Try looking at your MTU setting on your ifconfig.  YOU may be sending smaller chunks.  

try 

```
max xmit = 2048
```

Set

```
strict locking = no

log level = 1 

```

Then try the read raw setting as yes or no and see which one works best.

I would be interested in hearing if there is any improvement with any of these settings.  Also,  With what and how are you measuring throughput?

----------

## Aonoa

Sorry for the delayed response, I have been very busy. However, I have been using "mount -t cifs..." just as in your example. As for your suggestions about the smb.conf options, I'll have to try them when I get home later today. I have used bwm-ng, a commandline utility to measure bandwidth throughput. As well as watching dvd's play very badly from a samba share, suggesting an extremely crap throughput.

----------

## NightMonkey

Ah, CIFS doubled my sluggish transfer performance found with SMBFS. Thanks for the info!  :Smile:   :Smile:   :Smile: 

----------

## marjue

Hi 

I have an equel problem. Ich have Samba 3 on my Gentoo box for a long time. I use it with WinXP clients.

Now i noticed that transfers from the server are very slow (1MBit). Copying to the Server is OK. With FTP i reach 10MB/s.

Now the effect: I run a download with 1MB/s. While downloading i reload the shorewall. During the reload the speed of the download gets much faster. But the shorewall is not the bad guy. When i run the system without any firewall rules the download is slow too.   :Question: 

Now i put the "oplock=no" parameter in my global section and speed went up to ~2-3MB/s. But i thought this parameter has to be on "yes" for better performance ?

I trieed all the smb parameters which are known for better performance but nothing happened.

----------

## maudib

well..i can just confirm the problems...

having mounted samba shares (from a gentoo server) on a gentoo client using cifs, the speed maxes at 8-12Mb/s.

using ftp or nfs i get 25-35Mb/s. also using smbclient is around 30Mb/s.

have tried 3different NICs, netgear and dlink with different drivers but still no good.

----------

## marquischan

I am facing the same problem also

my lan card is Realtek 8139

before, tried LevelOne

The speed in FTP is normal but POOR in Samba

----------

## Gegolath

jepp, same Problem here.

Just came out all of the sudden, at least so it seems to me because i don't remember to reconfigured or installed something new or things like that.

I did several hours of testing and came to these results:

- Downloading/Streaming from the Server is slow like an old sleepy tortoise

- Anything except Samba works just fine (FTP, HTTP, NFS ..and so on)

- Linux or Windows as Client doesn't make any difference

- Copying from the Client TO the Server works fine and with full speed

- Taking the Server under Load (Network and/or CPU) moves the bandwith of the download up significant (doing an emerge, or running a find script or something similar...if you suspend the process...bandwith goes down..if you start it again bandwith goes up again...freaking weird?!)

- Recompiling Samba didn't work

- Tried Samba Version 3.0.14a and 3.0.20b with no difference at all

- Tried Kernel 2.6.12-r6 and 2.6.14-r5 with no difference at all

- Doesn't seem to be any Samba configuration behavior

Network Cards are:

Realtek 8169 (Server)

Marvel Yukon/Syskonnect (Client)

Both the Client (runs Windows also)  and the Server run on Gentoo

And thats my Samba config, but i think this mysterium is not an config failure

```

[global]

        hosts allow = 127.0.0.1 10.12.6.0/24 10.8.0.0/24

        hosts deny = 0.0.0.0/0

        #use sendfile = no

        #security = share

        workgroup = OLYMP.NET

        guest account = gegolath

        server string = Phoenix Samba Server %v

        interfaces = 10.12.6.1/24

        smb passwd file = /var/lib/samba/private/passdb.tdb

        passdb backend = tdbsam

        client NTLMv2 auth = Yes

        client lanman auth = No

        client plaintext auth = No

        #log level = 1 passdb:1 auth:1

        log level = 1

        log file = /var/log/samba/log.%m

        max log size = 50

        name resolve order = host lmhosts bcast

        #time server = Yes

        read raw = yes

        write raw = yes

        getwd cache = yes

        max xmit = 65535

        oplocks = yes

        socket options = IPTOS_LOWDELAY TCP_NODELAY SO_KEEPALIVE SO_RCVBUF=8192 SO_SNDBUF=8192

        strict sync = No

        load printers = No

        dns proxy = No

        homedir map =

        create mask = 0744

        directory mask = 0775

        #ClamAV mit Samba verwenden

        #vfs object = vscan-clamav recycle

        #vscan-clamav: config-file = /etc/samba/vscan-clamav.conf

        time server = Yes

[Filme]

        comment = Film Directory

        path = /opt/data2/Filme

        invalid users = root

        valid users = gegolath, cassandra, +users, +smbroot

        read only = No

[Data]

        comment = Fileserver Raid Daten Array

        path = /opt/data

        #guest ok = Yes

        veto files = /postgres/

        veto files = /Squidcache/

        admin users = gegolath

        invalid users = root

        read only = No

[Data3]

        comment = Fileserver Entertainment and Data Drive

        path = /opt/data3

        invalid users = root

        read only = No

[Data2]

        comment = Fileserver Video Media Drive

        path = /opt/data2

        invalid users = root

        read only = No

[Ebooks]

        comment = Fileserver Ebooks

        path = /opt/data/Ebooks

        invalid users = root

        read only = No

[Mp3s]

        comment = Fileserver Audio Files

        path = /opt/data/Audio

        invalid users = root

        read only = No

#[printer]

#       path = /dev/null

#       browseable = No

#       available = No

```

I hope somebody has the luck and the wisdom to reveal this enigma

At the moment I'am trying to recompile my glibc and then samba again...maybe this does the trick...i will let you folks know if it does change anything.

----------

## dspgen

Same issue.  Here are my test results

3 computers:

"S1" = Windows 2000 server

"C1" = 2.6.14-gentoo-r5 (k8 cpu)

"C2" = 2.6.14-gentoo-r5 (i686 cpu)

speed tests: (589MB file, determined by "date && copy x && date")

"C1" (NFS) from "C2" gets 15MB/s

"C1" (smbclient) from "C2" gets 27MB/s

"C1" (mount -smbfs) from "C2" gets 12MB/s

"C1" (smbclient) from "S1" gets 24MB/s

"C1" (mount -smbfs) from "S1" gets 0.185MB/s

"C2" (smbclinet) from "S1" gets 21MB/s

"C2" (mount -smbfs) from "S1" gets 9MB/s

"C1" (mount -smbfs) to "S1" gets 13MB/s

clearly there is something special about C1  :Sad: 

edit:

Tried using the kernel from "C2" on "C1", increased the speed to ~1MB/s.

switched to cifs:

"C1" (mount -cifs) from "S1" gets 13MB/s

----------

## dspgen

Now I have a problem with a WinXP client.

gentoo has DVD vob files on its hard disk.  when copying the vob files to another drive on that computer it get  30-40MB/s.

watching this DVD (via samba) it plays fine for a while. copying the a vob files get like 16MB/s.

After some time (2-10 hours after boot), the network connection slows to 10-300KB/s.

Reboot, and it works fine for a while again.

when it is going slow, I can smbclient to the WinXP and copy from WinXP at 5.5MB/s.

after rebooting (when it is going fast), smbclient to the WinXP and copy from WinXP gets 24MB/s

on the WinXP, copying a vob from the gentoo gets 19MB/s

```
ifconfig eth0 down && sleep 30 && ifconfig eth0 up
```

does not fix the problem. rebooting does.

Anyone have any ideas or other tests, logs, etc to look at?

----------

## dspgen

No one? no ideas on why network shares get slow after a while? please?

----------

## Merlin-TC

Any news here? I am having exactly the same problem. FTP transfers and all other network related things work fine just samba transfers FROM the server to a client are very slow ~1mb/s while uploading to the server is fine.

----------

## dspgen

I've had no problems since I replaced my network switch & cables (doh! I was using cat-5 with a gigabit switch - I replaced all my cables with new cat-6's) - strange that only samba had problems with the old switch/cables.

----------

## Merlin-TC

Well I am only running a 100mbit network but I only get max 1mb/s when downloading from the server. I have another switch so I might give that a try.

----------

## andrewwalker27

Same problem here, I'm only managing 300K/Bs which is rather painful when you're trying to transfer a video file across! I'm using ~x86_64

----------

## Dgege

I'm having exactly the same problem ! Everything works but samba. From client to server, I get good speeds. But from server to client, it's slooooooooooooow. I tried other distros (debian, suse) and I get the same problem ! I don't get it. I don't have much time right now, i'm finishing my masters. Once it's done, I'll trouble shoot, hopefully getting to the bottom of it !

Georges.

----------

## Dgege

ok guys, I think I narrowed down the problem to the network card. To everyone who is experience this problem, what network card module are you using ? I'm using via-rhine, which I suspect is the culprit.

Dgege.

----------

## marquischan

I have this problem before

After checking, the LAN card got problems

Another time i have problem in slow connection is I have set the log level to 100.

The machine is too slow to log down EVERY traffic.

----------

## motiv

To those who are getting reasonable speeds from gigabit (10-13MB/s),  I've found that adding the directio option to the mount options for cifs added about 9-10MB/s to the transfer rate.  I get peak transfers of 20-22MB/s now.

```
 mount -t cifs  -o directio,rsize=16384,wsize=16384 //Media/movies /mnt/movies 
```

I also have my samba server configured for read raw / write raw

```

[global]

  workgroup = XXX

  server string = MediaXXX Server

  smb passwd file = /etc/samba/private/smbpasswd

  username map = /etc/samba/smbusers

  socket options = TCP_NODELAY SO_KEEPALIVE

  read raw = yes

  write raw = yes

```

I can't say I've figured it out completely.  For some reason, I get better performance using Gnome to copy than using the cp command.

----------

## someone19

I just solved the same problem myself - I made samba my WINS server and pointed my XP boxes to it as such.

Now network browsing has gone from night to day and transfers take 75-90% of my 100mbit network (estamates using windows taskmgr network graph)

----------

## Ateo

Digging up an old thread....

My sluggish speeds between my laptop (gentoo) and my samba server (also gentoo) were fixed by swapping from smbfs to cifs... There has never been an issue between a windows client to my samba server.

----------

## darkphader

 *Gegolath wrote:*   

> And thats my Samba config, but i think this mysterium is not an config failure
> 
> [code]
> 
> [global]
> ...

 

OK, old thread but in case it helps spmeone...

That's not a valid workgroup name. NetBIOS workgroup and domain names are not hierarchical and contain no dots.

Chris

----------

## koskh

use in [global]

large readwrite = no

It had helped for my home workstations (Linux (samba 3)+ WindowsXP).

----------

## darkphader

 *darkphader wrote:*   

> That's not a valid workgroup name. NetBIOS workgroup and domain names are not hierarchical and contain no dots.

 

Correcting myself here. Although it is true that NetBIOS names are not hierarchical but apparently a dot is a valid character.

Chris

----------

## ervin.peters

 *Gegolath wrote:*   

> jepp, same Problem here.
> 
> Network Cards are:
> 
> Realtek 8169 (Server)
> ...

 

I got similar problems:

https://forums.gentoo.org/viewtopic-t-570392.html

I found out that poor smb performance is related to a broken udp-perfomance of the 8169 NIC in outgoing udp.

But, only in Gb Mode of the 8169 NIC, with 100Mbps it is ok.

ervin

----------

## kik0r

Same problem, I solved changing NIC.

My setup is a P5B with integrated gigabit (lspci said 03:00.0 Ethernet controller: Realtek Semiconductor Co., Ltd. Unknown device 8168 (rev 01)

The performance was perfect (65Mb/s on nfs with sata2 disk to my media center, fast ssh...) except for samba (I need to share to windows computer).

I was able to tweak the settings to have good performance it was something like 500kb/s. I noticed that running a find loop or a second copy was 

boosting the transfert to 4mb/s, pretty weird.

I add a spare gigabit controller, netgear basic gigabit, lspci said 07:02.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL-8169 Gigabit Ethernet (rev 10)

It's almost the same except it works great with samba !

The strange thing is it's the same kernel module for both gigabit adapter.

Also, I think I read somewhere Realtek as a new driver version 8.x and that it has been merged in kernel 2.6.22, I haven't tried, but it can also be a solution.

Maybe it help someone on this thread  :Smile: 

----------

## renaud91

Hello,

I am on a Gentoo 2007 up to date system.

I also had the same problem, and after 5 days playing with 2.4, 2.6 Kernel, Samba's versions, Samba's options, file systems, I finally changed my network card and asked to Samba to use this interface instead the realtek one (that I did not deactivate).

My problem was :

- copying file from windows to samba = very fast, normal Giga byte speed

- copying file from samba to windows = 3min for a 4Mg file ?????, unusable

- using FTP = no pblm at all, normal speed both sides

I also played with ethtool, changing options, but passing in 100Mbps changed nothing for me, and even if it had, I am on a Gb lan, I want Gb perf.

Note that I also tried the last Realtek driver version 8.0.x.x for 2.6 kernel, but it changed nothing at all.

My network card was an internal realtek 8111, that came with my Asus mother board. Now, it is a simple giga byte from linksys and it works perfecly (the wake on lan too, by the way  :Smile: ).

best regards,

Renaud.

Edit: November 2007, since weather was bad, I decided to re-install all my Gentoo server. Every thing went 'almost' fine, but after a few days I was able to re-install my samba server. Very funny thing happen then, since I was slow in the other way (server to client was slow), I checked if the samba used the realtek or not. No, it was using the 'normal an efficient' dlink one. So, what, I tried to play with all samba parametesr again, nothing ....

And finnaly, I found my problem, it was the IO Scheduller of my 2.6 Kernel, I set to CFQ and after a recompile, all went fine.

----------

## jeancf

I was experiencing very similar symptoms on my home server. I had excellent TX performance (i.e. serving files) at ~20MB/s and extremely poor RX performance (i.e. saving files on server) at ~ 0.5MB/s with both Linux and Windows clients.

My server is equipped with a Realtek 8169 Gigabit Ethernet NIC

gentoo-sources-2.6.24-r7

samba-3.0.28

The issue is related to the NIC. To resolve you have 2 options:

download and compile the latest driver from the Realtek web site (untested).

configure your kernel with Device Drivers->Network device support->Ethernet (1000 Mbit)->Realtek 8169 gigabit ethernet support as a module or in the kernel

select Use Rx Polling (NAPI) (EXPERIMENTAL)

This option was unchecked in my original configuration. Enabling it and recompiling the kernel gives me >20MB/s throughput in both TX and RX with Samba.

From the kernel help text:

 *Quote:*   

> NAPI is a new driver API designed to reduce CPU and interrupt load when the driver is receiving lots of packets from the card (...)

 

I hope this can help a number of you to get out of the ditch.

Enjoy!

/~jc

----------

## javeree

Same problem, but different NIC: RTL-8139

----------

