# 安装 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

# 开机自动挂载

  1. 写一个可执行脚本 smbinit ,内容如下:
#!/bin/sh
sudo mount.cifs //10.10.10.10/test /home/shylock/test -o username='test',password='password',vers=1.0
  1. 赋予 x 权限
sudo chmod +x /etc/init.d/smbinit
  1. 在 rc.local 中加入 echo "1234" | sudo -S "/etc/init.d/smbinit" , 如下:
rc.local
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.
echo "1234" | sudo -S "/etc/init.d/smbinit"
exit 0
shylock@ubuntu:~$

注:

  • rc.local 是一个启动时自动执行的脚本,如果没有自动执行,检查一下是否有 x 权限
  • "1234" 是 root 用户的密码,该语句表示用 sudo 执行脚本
更新于 阅读次数

请我喝[茶]~( ̄▽ ̄)~*

木 白 微信支付

微信支付

木 白 支付宝

支付宝

木 白 贝宝

贝宝