解决macos 下mount samba 的root权限问题
在macos 下mount samba 共享
需要在macos 下mount samba 共享的文件夹,一切痛苦的起源开始,使用用户 baihezi来执行命令。
第一次直接成功
$ sudo mount -t smbfs -o rw //shareuser@192.168.31.3/sharepath ~/sharepath
痛苦的开始—— 没有权限
虽然mount 成功了,但是 ~/sharepath
只有root
用户有权限,当前执行命令的用户baihezi 没有权限访问,其他任何用户都没有权限,访问不了。
遇到的问题1
$ mount -t smbfs //shareuser@192.168.31.3/sharepath /Users/ricolau/mountpath
# 报错
#mount_smbfs: mount error: /Users/ricolau/mountpath: File exists
#mount: /Users/ricolau/mountpath failed with 64
于是参考网上的一些教程,在 -o options 上加参数
遇到的问题2
$ sudo mount -t smbfs -o usmak=000 //shareuser@192.168.31.3/sharepath /Volumes/sharepath
mount_smbfs: -o usmak: option not supported
mount: /Volumes/sharepath failed with 1
遇到的问题3
sudo mount -t smbfs //shareuser@192.168.31.3/sharepath ~/sharepath -o dir_mode=0777,file_mode=0777
# 直接提示参数不对
第四次尝试
$ sudo mount -t smbfs -o username=shareuser,uid=1000,gid=1000,iocharset=utf8,rw,dir_mode=0777,file_mode=0777 //192.168.31.3/sharepath ~/sharepath
#再次失败 mount_smbfs: -o username: option not supported
#mount: /Users/rico/linkeast failed with 1
在经历过十几次失败后,
……
查找资料
苹果官方网站资料
- 我想在Mac中挂载公司的Samba共享盘。 https://discussionschinese.apple.com/thread/253826355
三方网站资料
- How to mount SMB share that can be accessed by anyone on Mac OS X El Capitan https://superuser.com/questions/997735/how-to-mount-smb-share-that-can-be-accessed-by-anyone-on-mac-os-x-el-capitan
终于成功
成功的脚本应该为:
mount成功:
mount -t smbfs -o soft,noowners,noatime,nosuid //shareuser@192.168.31.3/sharepath ~/mypath
umount 成功:
umount ~/mypath