Slow performance accessing Ubuntu Samba folders
I have a computer at home with an Ubuntu Server 14.04. This server has several hard disks that are shared using Samba.
I have an iMac with OS X El Capitan 10.11.5 and I use one of the shared disks to store some information. I'm accessing this disk a lot of times to write and read information.
The performance of the Finder is really slow compared with my Ubuntu laptop and my girlfriend window's laptop...
The configuration for the disk on Samba is this:
[MYDATA]
comment = my coment...
path = /path/to/disk
browsable = yes
guest ok = yes
read only = no
create mask = 0755
I would like to know if the configuration of the disk should be different in any way, or maybe if I need to add some configuration in my Mac.
I also noticed that sometimes when I try to rename a folder inside this Samba share my Mac usually ask for my root password to modify the folder's name.
Solution 1:
You should avoid using SMB on OS X (IMHO) as it has been buggy since the days of Snow Leopard (10.6), for me at least.
A quick Google search limited to this year alone brings up a myriad of issues regarding OS X and slow SMB implementations.
There are a few things you can try:
- Use the SMB2 protocol by mounting your share
cifs://<whatever your share name is>
-
Enable AFP (Netatalk) on your Ubuntu server and connect to the mount points using
afp://<whatever your share name is>
- Setup NFS on Ubuntu and mount them on OS X
Personally, if I have found CIFS good, AFP better, and NFS (even though it's much older) to be the best in terms of performance.
Solution 2:
I had the following settings in smb.conf on an Ubuntu Samba server.
socket options = SO_RCVBUF=8192 SO_SNDBUF=8192
This seems to have been causing a slow down of large file transfers to/from macOS. The slow down was around a factor of five, as compared with scp between the same machines. Although increasing these numbers helped, the best idea is probably to comment out that configuration line entirely, letting the kernel adjust the buffer size dynamically. This made smb file transfers take around the same amount of time as scp file transfers, i.e. about five times faster.
The other change I made was to add this line to the share definition section in smb.conf.
vfs objects = fruit streams_xattr
This enables the Samba "fruit" module for handling connections from macOS. It affects a number of behaviors and makes available various additional options (see samba docs here), but specifically helps with the speed of scanning large directories.