1

I set up an home server using my Raspberry Pi 3 Model B. This server is accessed from Linux distros, Mac OS, and Windows on the local network. I've chosen to set up the server using the smb protocol.

Now I'm connecting to it using my ubuntu laptop mounting it using smb vers 3.0. The download rate is about 1 MByte/s, which seems a bit slow to me, since the ethernet port should allow up to 100 Mbit/s.

Is there something I could do to increase the transfer rate?


EDIT: I'm using an external hard drive connected via USB (which should not be the bottleneck, though) formatted as ext4

  • 1
    You might want to mention what file system you are using with the server shares, and where they are located (on the SD card? an external USB drive?). – goldilocks Jan 16 '18 at 21:30
  • the ethernet port should allow up to 100 Mbit/s is that achievable on a Pi? Fastest I've seen is about 60Mbit (which is still about 7.5MByte though) – Jaromanda X Jan 16 '18 at 23:51
  • @Jaromanda theoretically should be 100Mbit/s. I found some benchmarks on the internet saying it is effectively 70MBit/s which, as you also say, is still almost 10x faster than 1MB/s – David Jan 17 '18 at 6:57
  • A lot of bottlenecks are possible here, on the software and hardware side (load@RPi load@your laptop, malware scanner, connectivity issues, cable, router, NIC and many more)! We need more details. I would investigate stepwise: how is the access time at local access, from the RPi itself? – Fabian Jan 17 '18 at 11:06
  • What class SD are you using? Is everything cabled directly to the router (without homeplugs or WiFi)? Any cables near electric sockets? – Andy Anderson Jan 17 '18 at 22:27
2

there are several things here, although the physical ethernet connection is 100Mbits/s the ethernet chip is hung off of a usb bus that is shared with other devices, so as quoted above the maximum actual throughput is about 60Mbits/s.

secondly because ethernet uses whats known as 8/10 encoding for error detection/correction the maximum throughput in bytes is 1/10th of that in bits (6MB/s)

thirdly, as mentioned before the USB bus is now shared between your HDD and the ethernet, so the max throughput drops even further (by at least half, so max of ~2.5MB/s)

fourth, all the resources of the pi are subject to contention (being fought over) the CPU is less of an issue because of the multiple cores, but samba is not the only thing accessing the ethernet connection, nor is it the only thing using the RAM these can all slow it down further.

and lastly, no software is perfect, I don't know about the samba source, but the linux kernel copies data multiple times from buffer to buffer in the process of sending it to the physical interface (this is why some big companies (i think the BBC or netflix?) have written their own network code to get past the bottleneck)

all these things slow it down, so tbh in the real world there isn't anything you can do to improve the speed. if you really need speed then you need to invest in a different SBC (single board computer) with better interfaces such as sata and/or native ethernet

  • I see. Actually I didn't know about the sharing of the USB bus. Very interesting. Thanks. In the end I just want to see if there are possibilities to increase to speed. It's not vital, though – David Jan 18 '18 at 8:01
3

SMB transfer speeds can be quite disappointing, especially when handling lots of small files. Then again, an RPi might not be the best choice as a NAS/file server in the first place. Still, just 1 MB/s is quite slow, even when using SMB as transfer protocol.

RPi 3 Model B uses its USB 2.0 hub to handle ethernet, and thus your network shares its bandwidth with ALL connected USB devices. However, this does not limit maximum Fast Ethernet speed by itself. USB 2.0 data rate is 480MBit/s, more than enough to serve a 100MBit/s Fast Ethernet connection, while still leaving 380MBit/s for other devices. On the other hand, any current HDD can easily fully utilize USB2 on its own, at the very least when reading from it.

Since your HDD can serve data faster than Fast Ethernet can transfer it, you should be able to get near the 9 MB/s mark when reading large files. With lots of small files (<256kB), protocol overhead will hurt transfer rates, but you still should expect about 2 MB/s.

Before you start fiddling with your SMB settings, try to establish where your bottleneck is:

  • Ethernet connection
  • HDD attachment
  • file system
  • SMB configuration

To rule out problems with your Ethernet config/cable or your HDD/HDD-USB-Bridge/USB-Cable, run some speed tests.

iperf or iperf3 will measure your Ethernet speed, and should report results similar to those on my RPi:

pi@pi:~# iperf3 -c 192.168.1.20
        Connecting to host 192.168.1.20, port 5201
    [  4] local 192.168.1.28 port 49840 connected to 192.168.1.20 port 5201
    ...
    - - - - - - - - - - - - - - - - - - - - - - - - -
    [ ID] Interval           Transfer     Bandwidth       Retr
    [  4]   0.00-10.00  sec   113 MBytes  94.5 Mbits/sec    0             sender
    [  4]   0.00-10.00  sec   112 MBytes  94.2 Mbits/sec                  receiver

If your results are much lower, your Ethernet might be the culprit. Check your Ethernet config, try a different cable and make sure any switch or hub involved is functioning.

hdparm will measure your HDDs reading speed (quite likely limited by RPi's USB2 host), and therefore should look similar to mine:

pi@pi:~# hdparm -tT --direct /dev/sda
/dev/sda:
 Timing O_DIRECT cached reads:    64 MB in  2.01 seconds =  31.78 MB/sec
 Timing O_DIRECT disk reads:  98 MB in  3.06 seconds =  32.03 MB/sec

If your results are substantially lower, maybe try a different USB cable, and make sure your HDD is sufficiently powered - an external power supply for your HDD is recommended. You could also connect your USB HDD to a different computer and compare transfer speeds there, just to be sure.

If your results fall within the same range as mine, check your hdd file system format: Avoid NTFS as it's quite CPU intensive. Though that shouldn't be much of an issue with an RPi 3 Model B, consider switching to ext4 if you can.

If your speed is still slow, it is likely that indeed SMB is limiting transfer speeds, and you should try some of the SMB config tweaks on your RPi suggested by other posters. Additionally, consider tweaking your SMB client configs as well.

0

I obtained the best results using Samba under Open Media Vault the Operative System optimized for NAS use case: https://www.openmediavault.org

If you want to try in your existing Samba, you can try editing smb.conf and adding this on the [global] section:

max xmit = 65535
socket options = TCP_NODELAY IPTOS_LOWDELAY SO_SNDBUF=65535 SO_RCVBUF=65535
read raw = yes
write raw = yes
max connections = 65535
max open files = 65535
0

I had similar issue, but the issue was from the SMB and not the HW. My SMB upload was 300kB/s. Other connections worked fine and almost saturated the network. (similar board but not with USB and ethernet on same hub) Few tests to check first:

  • Up/Down speed using SMB?
  • Is it file size/type dependent?
  • Is it the external USB or also the internal SD card?
  • Compare with FTP or HTTP?

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.