正确安装Windows共享的方法

我通过在/etc/fstab添加以下行将Windows共享安装到我的Ubuntu 11.10系统:

//serveraddr/sharedfolder /mnt/foldername/ smbfs credentials=/home/myname/.smbpasswd 0 0

在这里使用教程 。

但是权限存在问题。 mount文件夹的所有者是root 。 我无法在挂载点创建任何文件夹或文件是我不成为根。 即使我无法将所有权更改为我的默认用户

sudo chown -R myname .

我用google搜索,看到它可能源于Windows文件格式(fat32 / ntfs)无法保存所有权的事实。 但是当我通过samba连接到同一个位置时

smb://serveraddr/sharedfolder

通过提供我的凭据,我有权在不作为根的情况下编写。

如何让它写入已安装的文件夹?

不要使用smbfs ,新协议的名称是cifs及其包cifs-tools (如果你还没有安装它的话。

而是在你的fstab使用这一行

 //server/share /mnt/mountname cifs username=server_user,password=user_password,iocharset=utf8,file_mode=0777,dir_mode=07‌​77 0 0 

哪里

 server = your server that you are trying to access share = mapped share on that server /mnt/mountname = any folder that you created with sudo /mnt/ username = the name of the user on that server that can access the mount password = the password for that user 

之后,您可以使用sudo mount -a进行测试,如果您没有遇到任何故障,可以安全地重新启动以查找挂载在/mnt/共享。

要在fstab上使用凭证文件而不是usernamepassword参数,您可以使用这两行创建一个文件,这样您的用户名和密码就不会在fstab中明确显示

sudo nano /etc/cifspwd

将这些行添加到文件中

 username= password= 

按ctrl + x键,然后按y键保存文件。

保护它

sudo chmod 600 /etc/cifspwd

使用此行而不是之前的行

 //server/share /mnt/mountname cifs credentials=/etc/cifspwd,iocharset=utf8,file_mode=0777,dir_mode=07‌​77 0 0 

在此之后,重新启动是安全的,您应该安装并安装您的详细信息。