一、首先要确保内核配置是正确的:
以LINUX-2.6.12x为例:
1、在内核配置选项中
Kernel selection --->customize kernel settings;
File systems ---> Network File systems --->如下图进行选择:
support NFS file systems + Provide NFSV3 client support;
注意:Provide NFSV3 client support(NFS客户端) 选项必须选中,否则在挂载是会出现以下错误:Protocol not supported ;
2、在busbox中选择mount,umount命令:
Customize Busybox Settings--->Linux system Utilities --->mount->support mounting NFS file systems + support /etc/fstab and -a
二、配置开发板与Linux属于同意网段:保证互相可以ping通;service network restart 更改IP后需要重新启动网卡;
三、、在/etc/exprots文件中添加需要共享的目录,权限等信息;
四,、开启相关服务:service portmap restart (动态端口映射,需要在NFS之前启动,默认应该是启动状态)
service nfs restart
service iptables stop
五,、在Linux系统,测试NFS能否成功;
六、在开发板测试NFS能否成功;
七、NFS失败示例:
1、mount failed:inalid argument; 检查busybox是否配置正确:参照2;
2、Protocol not supported:检查kernel配置是否正确:参照1;
3、portmap:server localhost not responding,time out
RPC:failed to connect to portmap(errno -t)
mount : mount -t 192.168.2.55:/test on /mnt failed:input /output failed;
nfs mount 默认选项包括文件锁,依赖于portmap提供的动态端口分配功能;
解决办法:kill lockd 或者加选项:mount -o nolock;
nolock这个选项是针对NFS所特有的:Disable NFS locking. Do not start lockd. This has to be used with some old NFS servers that don't support locking.
八、挂载成功:
mount -o nolock -t nfs 192.168.2.55:/root/test /mnt/share;