ubuntu22.04 SMB连接速度过慢修复
自从更新到了 22.04之后,本机smb连接服务器传输文件速度慢的难以忍受,特别是映射后用vscode、Android Studio打开项目慢的出奇,保存个文件也要30s+,实在是受不了,特地花时间解决,记录一下解决方法.
修改smb配置文件:
- 备份原配置: sudo cp /etc/samba/smb.conf /etc/samba/smb.conf.bak
- 打开配置文件: sudo vim /etc/samba/smb.conf
- 在 [global] 配置内添加:
[global]
......
# 添加的配置 -- start
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
max xmit = 65535
max connections = 0
deadtime = 0
# 添加的配置 -- end
[printers]
comment = All Printers
- 测试配置是否正确: testparm
- 出现如下结果即正常
Load smb config files from /etc/samba/smb.conf
Loaded services file OK.
Weak crypto is allowed
......
Press enter to see a dump of your service definitions
- 重启SMB: /etc/init.d/smbd restart
Restarting smbd (via systemctl): smbd.service.
- 验证速度是否正常,一般是ok的,如果不行,继续
- 安装cifs: sudo apt install cifs-utils -y
- 更新samba: sudo apt-get install samba -y
- 防火墙豁免: sudo ufw allow samba
- 重启即可