通过samba让linux读取windows共享文件夹下的文件

浏览次数:2648 关键词 ( 共享文件夹  文件  samba  linux  )

通过samba让linux读取windows共享文件夹下的文件

Linux访问Windows共享文件夹,关于mount <wbr>cifs的一个问题

首先在Windows机器上共享出一个software目录,设置好目录的访问权限。本地Windows机器ip地址为192.168.10.58

Linux访问Windows共享文件夹,关于mount <wbr>cifs的一个问题

然后在linux上执行:

Linux代码   mount -t smbfs -o username=administrator,password='' //192.168.10.58/software /share
或mount -t cifs -o username=administrator,password='' //192.168.10.58/software /share
如果提示mount: unknown filesystem type 'smbfs',mount不了windows的共享盘,是因为RHE5的kernel已经不再支持smbfs,而改用Common Internet File Systemcifs(cifs)取代了原有的smbfs,所以,将原命令中的smbfs改成cifs即可。
如图:
Linux访问Windows共享文件夹,关于mount <wbr>cifs的一个问题

Linux访问Windows共享文件夹,关于mount <wbr>cifs的一个问题

这样就可以了。如果测试时,提示没有写文件权限,则执行:

Linux代码  
  1. umount /share  
  2. mount -t smbfs -o rw,fmask=775,dmask=777,uid=www,gid=www,username=administrator,password='' //192.168.10.58/software /share 
  3. 如果umount时报错:unmount error 16 = Device or resource busy,则需要使用umount -l /var/www/share命令来卸载,这是启用了umount lazy模式,在需要卸载的对象不忙的情况下卸载。
Linux访问Windows共享文件夹,关于mount <wbr>cifs的一个问题

Linux访问Windows共享文件夹,关于mount <wbr>cifs的一个问题