通过nfs及mount我们可以实现不同pc机上文件共享,具体实现步骤如下:
(1)编辑 etc/exports文件,添加文件夹和属性如下:
/opt/rootbox 10.10.19*(rw,no_root_squash,async)
/opt/rootbox 目录下的文件及文件夹能够被ip以10.10.19.*类型的pc机共享,当然也可设置不同的共享权限。
(2)然后重启nfs服务, 命令如下:
service nfs restart
(3)使用nfs
使用nfs时一般使用下面的命令进行mount。
mount -t 服务器ip:目录 本地目录
(eg:mount 192.168.0.1:/arm2410s /host )
如果mount不成功,请先检查网络是否是好的,ping一下服务器,能ping通但是mount不上,关掉本地的防火墙再试试:service iptables stop。
又如:
本机地址为9.185.43.201 ,mount /tmp 到 /nfs2
> mount 9.185.43.201:/tmp /nfs2
> umount /nfs2 (注意不要在当前目录下unmount)
描述:
我在arm上通过NFS共享文件时出现下面的错误提示
nfs:server is not responding,still trying
原因分析:NFS 的默认传输协议是 UDP,而PC机与嵌入式系统通过UPD交互时就会出现严重的网卡丢包现象。
解决方法:在客户端改用TCP协议,使用下面的命令,
#mount -t nfs -o nolock -o tcp 192.168.1.161:/opt /opt
client 端mount 后无任何提示信息 ls 也正常,所以nfs已经挂载成功。到这是不是就该结束了?mount成功,本来后面应该一切都OK了,可没想到的是当复制文件到client本地的时候出现了如下问题:
nfs: server 192.168.40.111 not responding, still trying
nfs: server 192.168.40.111 not responding, still trying
nfs: server 192.168.40.111 OK
nfs: task 192 can't get a request slot
出现上面问题的原因──不同版本内核默认的nfs块大小不同。照常理找找看有没有人遇到同样的问题。果真:http://wiki.ltsp.org/twiki/bin/view/Ltsp/NFS (说明了原因,也给了解决方案)不过感觉还是不怎么爽,给内核加启动参数。此时已到晚上好点多,先闪人吧,要不然得走路回去了。第二天突发,mount可以指定nfs的读写块大小,自然上面遇到的问题很容易就能解决(mount -t nfs -o rsize=8192,wsize=8192 servername:/serverdir /clientdir)。