可以的,CentOS 下 mount 是可以挂载 SMB(Samba / CIFS)共享的,不过需要使用 CIFS 文件系统类型,而不是普通的 mount 直接识别 SMB。
CentOS 默认不一定带 CIFS 支持:
# CentOS 7
yum install -y cifs-utils
# CentOS 8 / Stream
dnf install -y cifs-utils
mount -t cifs //smb_server/share /mnt/smb \
-o username=your_user,password=your_pass
示例:
mount -t cifs //192.168.1.100/public /mnt/smb \
-o username=admin,password=123456
vim /etc/smbauth
内容:
username=your_user
password=your_pass
权限:
chmod 600 /etc/smbauth
mount -t cifs //192.168.1.100/public /mnt/smb \
-o credentials=/etc/smbauth
| 选项 | 说明 |
|---|---|
uid=1000 |
指定挂载后文件属主 |
gid=1000 |
指定组 |
iocharset=utf8 |
中文支持 |
vers=2.0 / 3.0 |
SMB 协议版本 |
sec=ntlmssp |
认证方式 |
示例:
mount -t cifs //192.168.1.100/share /mnt/smb \
-o credentials=/etc/smbauth,uid=1000,gid=1000,iocharset=utf8,vers=3.0
//192.168.1.100/share /mnt/smb cifs credentials=/etc/smbauth,iocharset=utf8 0 0
⚠️ 注意:
- 网络未就绪可能导致挂载失败
- 可加
_netdev选项
//192.168.1.100/share /mnt/smb cifs credentials=/etc/smbauth,_netdev 0 0
Host is down尝试指定版本:
vers=2.0
或
vers=1.0
iocharset=utf8
加:
uid=你的用户id,gid=你的组id
如果你愿意,可以告诉我:
我可以给你一份完全适配你环境的挂载命令。