环境:Widows+VM12.5+CentOS6.5
1、nfsc测试前的配置如下
(1)虚拟机下linux主机的IP地址为:192.168.1.235
(2)Widows主机的IP地址为:192.168.1.236
(3)开发板的IP地址为:192.168.1.230
2、在linux下ping开发板,结果如下
[root@localhost /]# ping -c 4 192.168.1.230
PING 192.168.1.230 (192.168.1.230) 56(84) bytes of data.
64 bytes from 192.168.1.230: icmp_seq=1 ttl=64 time=1.44 ms
64 bytes from 192.168.1.230: icmp_seq=2 ttl=64 time=1.05 ms
64 bytes from 192.168.1.230: icmp_seq=3 ttl=64 time=0.591 ms
64 bytes from 192.168.1.230: icmp_seq=4 ttl=64 time=0.431 ms
--- 192.168.1.230 ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3004ms
rtt min/avg/max/mdev = 0.431/0.882/1.447/0.399 ms
3、通过上面的结果可以看出linux主机与开发板之间的网络是通畅的,不管nfs之前的状态如何,都使用指令“service nfs restart”,如果nfs安装好了,则会出现下面的结果。
[root@localhost /]# service nfs restart
Shutting down NFS daemon: [ OK ]
Shutting down NFS mountd: [ OK ]
Shutting down NFS quotas: [ OK ]
Shutting down NFS services: [ OK ]
Shutting down RPC idmapd: [ OK ]
Starting NFS services: [ OK ]
Starting NFS quotas: [ OK ]
Starting NFS mountd: [ OK ]
Starting NFS daemon: [ OK ]
Starting RPC idmapd: [ OK ]
4、linux主机下的测试nfs是否配置好,首先在/etc/exports文件中添加文件目录和权限,exports的具体内容如下:
/test *(rw,sync,no_root_squash)
/nfsroot *(rw,sync,no_root_squash)
接着在终端里,使用挂载命令“mount -t nfs -o nolock 192.168.1.235:/nfsroot /test”,无提示则表示成功,然后使用“ ls test”就可看到/nfsroot目录下的内容,说明nfs在linux主机配置成功了,下一步就是要与开发板进行挂载了。
[root@localhost /]# mount -t nfs -o nolock 192.168.1.235:/nfsroot /test
[root@localhost /]# ls testexamples examples-mini210-20120912.tgz
[root@localhost /]#
5、取消上一次的挂载,使用指令“umount test”,成功则没有提示,然后再次使用“ls /test/” 就可看到/test目录下的内容与/nfsroot目录下的内容不一样。
[root@localhost /]# umount test
[root@localhost /]# ls /test/
linux-2.6.35.7 linux-3.0.8
linux-2.6.35.7-20121027.tgz linux-3.0.8-20161011.tgz
[root@localhost /]#
6、开发板挂载NFS。开发板要挂在的目录是/nfsroot,所以要先取消在主机上挂载。
在开发板终端上使用指令"inetd",让后使用"mount -t nfs -o nolock 192.168.1.235:/nfsroot /mnt",会出现如下提示:"mount: RPC: Unable to receive; errno = No route to host"
[root@FriendlyARM /]# inetd
[root@FriendlyARM /]# mount -t nfs -o nolock 192.168.1.235:/nfsroot /mnt
mount: RPC: Unable to receive; errno = No route to host
mount: mounting 192.168.1.235:/nfsroot on /mnt failed: Bad file descriptor
[root@FriendlyARM /]#
7、解决办法,在linux主机下使用指令service iptables start和service iptables stop,会出现如下提示,则表示成功。
[root@localhost /]# service iptables start
[root@localhost /]# service iptables stop
iptables: Setting chains to policy ACCEPT: filter [ OK ]
iptables: Flushing firewall rules: [ OK ]
iptables: Unloading modules: [ OK ]
[root@localhost /]#
8、然后在开发板上再次使用mount -t nfs -o nolock 192.168.1.235:/nfsroot /mnt,
就可以了,正确结果如下所示:
[root@FriendlyARM /]# mount -t nfs -o nolock 192.168.1.235:/nfsroot /mnt
[root@FriendlyARM /]# ls mnt
examples examples-mini210-20120912.tgz
[root@FriendlyARM /]#