Windows 共享已通过 fstab 挂载并运行,但共享主机重新启动时共享丢失
有没有办法将共享配置为在共享主机返回时自动挂载?
答案1
以 Root 身份编辑/etc/fstab
add //Ip_Server/folder_server /folder_local cifs username=user_windows,password=password-windows,rw,users,uid=user_linux,gid=group_linux 0 0
例子:
//192.168.0.100/FolderInWin\share_Folder_InWin /home/pepe/MyFolder cifs username=pepeinWin,password=pepeinWin1234,rw,users,uid=pepe,gid=users 0 0
每次启动电脑时它都会安装
答案2
使用 autofs 来实现这一点
#Create sharepoint at: /sharebase/share
service autofs stop
nano /etc/auto.master
Add: /sharebase /etc/auto.cifs --timeout=300 --ghost
nano /etc/auto.cifs
Add: share -fstype=cifs,domain=mydomain,uid=www-data,gid=www-data,iocharset=utf8,file_mode=0777,dir_mode=0777,credentials=/root/.cifs ://SAMBA.share/
nano /root/.cifs
Add: username=myusername
Add: password=mypassword
service autofs start