开发板挂载虚拟机下的NFS目录

来源:互联网 发布:mac下载flash插件 编辑:程序博客网 时间:2024/05/22 08:27

刚刚完成在开发板中挂载VMWare下的Ubuntu中的NFS服务目录,以下是本人操作的过程:

 

一、 安装NFS服务:

1. sudo apt-get install nfs-kernel-server

2. 配置

    gedit /etc/exports

    修改后的文件内容如下:

   

    ......

    ......

    #/srv/nfs4/homes gss/krb5i(rw,sync,no_subtree_check)

    #

 

    /home/share/NFS 192.168.10.*(rw,sync,no_root_squash)

 

其中/home/share/NFS是将要被挂载的目录,192.168.10.* 是被允许挂载主机的客户端地址段,如果允许任意客户端都可以访问,则将此值设为*即可。

 

  gedit /etc/hosts.allow

  修改后的文件内容如下:

  ...

  ...

  # for further information.

  #

 

portmap: 192.168.10.

locked: 192.168.10.

rquotad: 192.168.10.

mountd: 192.168.10.

statd: 192.168.10.

 

3.启动服务:

   sudo /etc/init.d/nfs-kernel-server start

 

4.测试:

 在主机中,执行此命令验证NFS是否已经正常启动

  sudo mkdir /mnt/NFSTest

  sudo mount -t nfs 192.168.10.161:/home/share/NFS /mnt/NFSTest

  如果没有错误提示,证明NFS服务已经正常启动,并且挂载目录可以被正常挂载。

 

二、开发板挂载准备工作

 

1. VMWare设置为 Bridge 网络连接方式。

2. 执行以下命令设置ubuntu的IP地址(该地址要和开发板中所设置的网段相同)

    ifconfig eth0 192.168.10.161 netmask 255.255.255.0

3. 在开发板上插上网线,将主机与开发板用串口线连接,在超级终端或minicom中,尝试是否能够ping通主机ubuntu的网络

    ping 192.168.10.161

    如果显示类似64 bytes from 192.168.10.161: icmp_seq=5 ttl=64 time-1.0 ms的提示信息,则可以确定主机同开发板的网络连   接没有问题。

4. 尝试挂载:

    mount -o nolock -t nfs 192.168.10.161:/home/share/NFS /mnt

  如果没有任何错误提示,则挂载成功,执行

    ls /mnt

   可以看到主机 /home/share/NFS目录下的文件

 

 

问题解决:

 

1. 在开发板中不能ping通主机,提示ping: sendto: Network is unreachable

   原因可能是主机和开发板的网段不同,通过ifconfig eth0 xxx.xxx.xxx.xxx netmask xxx.xxx.xxx.xxx命令修改主机或开发板中任一端的IP地址。

 

2. 挂载时提示:

   mount: RPC: Unable to receive; errno = Connection refused

   mount: nfsmount failed: Bad file descriptor

   mount: Mounting 192.168.10.161:/home/share/NFS on /mnt failed: Invalid argument

  原因可能是主机中的/etc/hosts.allow 文件没有被正确设置,其中的IP地址段要设置成和开发板一致,或者/etc/exports中的共享目录和刚才所执行的命令中指定的目录不同,或者是此文件中的IP段与主机不同。

 

3. 挂载时提示:

   rpcbind: server localhost not responding, time out

   RPC: failed to contact local rpcbind server (errno 5).

   ...

   ...

   原因可能是在执行挂载命令时没加入-o nolock选项。  

 

参考信息:

http://blog.mcuol.com/User/stbcxj/Article/15379_1.htm

http://hi.baidu.com/luo_dean/blog/item/30992df2d58c5d1bb17ec5e5.html

http://wb127.blog.51cto.com/2232662/401732

 

原创粉丝点击