1. linux主机自动挂载cifs
方法一:/etc/fstab中添加挂载项
vim /etc/fstab
添加挂载项,如下:
![](https://img2018.cnblogs.com/blog/956625/201907/956625-20190724204456662-191969636.png)
方法二:/etc/rc.local中添加挂载命令
mount -t cifs -o username=user1,password=111111 //10.1.2.31/smb /mnt/smb
2. windows主机自动挂载cifs
编写xxx.bat文件
@echo off net use y: \10.1.1.31smb "111111" /user:"user1"
其中,y为网络驱动器盘符,111111为登录用户的密码,user1为登录用户
将该文件放至目录C:UsersAdministratorAppDataRoamingMicrosoftWindowsStart MenuProgramsStartup下,重启即可自动挂载。
ps:可能有隐藏目录,需要在文件“查看”属性中勾选“隐藏的项目”,如下:
![](https://img2018.cnblogs.com/blog/956625/201907/956625-20190724205509430-984363934.png)
参考:windows自动重连网络驱动器 https://blog.csdn.net/xiexingshishu/article/details/42081543