Samba 4 has high CPU usage when accessing mapped drive through Windows

9,817

Possibly a bit late but I found this, while having a similar problem.

I have a Raspberry Pi B+ with samba configured as a drive store, with a direct connection to my laptop over Ethernet.

My setup is as follows:

  • several external hard drives connected to raspberry pi.
  • Raspberry pi uses direct Ethernet connection to my laptop.

I have found:

  • high cpu usage by smbd when reading from external (45%)
  • high cpu usage by mount.ntfs when writing to external (46%)

Considering specs of B+, it seems somewhat believable since a simple apt update takes a minute of so if just refreshing list...

This might make for some good reading

Share:
9,817

Related videos on Youtube

Beauvais
Author by

Beauvais

Updated on September 18, 2022

Comments

  • Beauvais
    Beauvais over 1 year

    I have noticed that when I access my Samba share from Windows, the smbd daemon will always use aprox 10-20% CPU - no matter if the share is used or not from Windows. Even if I close the share/window, smbd will continue using CPU and only a reboot/shutdown of my Windows can get the CPU usage down to normal.

    This is when I have just rebooted/started my Windows - the share is mapped but not accessed yet. It will have this "red" status in Windows until I access it:

    Share as seen from Windows after a reboot

    Before I do anything else I check the smbstatus and top on my Linux:

    smbstatus after a reboot

    There is no problem so far - the CPU usage is not noticable at all in top so everything is still good.

    BUT ... when I then access the share from Windows, the Linux CPU immediately raises to 10-20%:

    High CPU when drive is accessed

    And the smbstatus always shows some locked(?) files which for sure(?) is not accessed from my Windows:

    Files accessed when mapped drive is accessed

    The testparm shows my smb.conf configuration:

    Samba configuration file

    The only way I can "fix this" is by either rebooting my Windows or unmap the drive/share.

    One more strange thing - when I have unmapped the share/drive, I can of course still access the share via UNC... and when accessing it through UNC it does NOT raise the CPU at all!? Weird!

    My hardware is quite recent/uptodate:

    Server: Core i5 1.5-2.9GHz dual core/HT 16GB RAM Samsung 850 Pro (512GB)

    Client: Windows 8.1

    I have used the same configuration on a CentOS 6 installation without any problems. I have also tried disabling whatever I think can communicate with the network share on my Windows computer (antivirus and backup software).

    Can anyone help nailing this problem down?

    • Preexo
      Preexo over 9 years
      I observe the same behavior on one of my samba servers, did you ever find an explanation for that and is it really abnormal?
    • Michael D.
      Michael D. about 7 years
      If samba isn't the dance you want to dance use NFS. Linux/*nix native network fs and maybe a bit less resource hogging. superuser.com/questions/525473/…
    • TCB13
      TCB13 about 7 years
      I've the same problem with macOS clients here.