日期:2014-05-16  浏览次数:20649 次

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

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

然后在linux上执行:

?

mount -t smbfs -o username=gaohf,password=gaohf //192.168.10.152/share /var/www/share

?

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

?

umount /var/www/share
mount -t smbfs -o rw,fmask=775,dmask=777,uid=www,gid=www,username=gaohf,password=gaohf //192.168.10.152/share /var/www/share

?

如果提示mount: unknown filesystem type 'smbfs',mount不了windows的共享盘,是因为RHE5的kernel已经不再支持smbfs,而改用Common Internet File Systemcifs(cifs)取代了原有的smbfs,所以,将原命令中的smbfs改成cifs即可。

?

如果umount时报错:unmount error 16 = Device or resource busy,则需要使用umount -l /var/www/share命令来卸载,这是启用了umount lazy模式,在需要卸载的对象不忙的情况下卸载。