# 安装 cifs-utils
| sudo apt-get install cifs-utils |
# 查看远程目录
| shylock@ubuntu:~$ smbclient -L 10.10.10.10 -U test%password |
| |
| Sharename Type Comment |
| --------- ---- ------- |
| project Disk |
| IPC$ IPC IPC Service (Samba Server Version 4.3.11-Ubuntu) |
| test Disk Home Directories |
| SMB1 disabled -- no workgroup available |
# 挂载远程目录
| sudo mount.cifs //10.10.10.10/test /home/shylock/test -o username='test',password='password',vers=1.0 |
注:默认 mount.cifs
挂载的是 smb3
, 如果要挂载 smb1
,要加上 ,vers=1.0
# 开机自动挂载
- 写一个可执行脚本
smbinit
,内容如下:
| #!/bin/sh |
| sudo mount.cifs //10.10.10.10/test /home/shylock/test -o username='test',password='password',vers=1.0 |
- 赋予
x
权限
| sudo chmod +x /etc/init.d/smbinit |
- 在 rc.local 中加入
echo "1234" | sudo -S "/etc/init.d/smbinit"
, 如下:
rc.local | #!/bin/sh -e |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| echo "1234" | sudo -S "/etc/init.d/smbinit" |
| exit 0 |
| shylock@ubuntu:~$ |
注:
rc.local
是一个启动时自动执行的脚本,如果没有自动执行,检查一下是否有 x
权限"1234"
是 root 用户的密码,该语句表示用 sudo 执行脚本