关于自己遇到的nfs 挂载问题:

    xiaoxiao2021-03-25  95

    对nfs的基本认识:

    NFS(work File System, 网络文件系统)可以通过网络将分享不同主机的目录——可以通过NFS挂载远程主机的目录, 访问该目录就像访问本地目录一样! NFS运行在SUN的RPC(Remote Procedure Call, 远程过程调用)基础上, RPC定义了一种与系统无关的方法来实现进程间通信. 由此, NFS server也可以看作是RPC server. 正因为NFS是一个RPC服务程序, 所以在使用它之前, 先要映射好端口——通过portmap设定. 比如: 某个NFS client发起NFS服务请求时, 它需要先得到一个端口(port). 所以它先通过portmap得到port number. (不仅NFS, 所有的RPC服务程序启动之前, 都需要设定好portmap。

    情况一:在板子上进行如下操作:

    设置开发板的IP与我Ubuntu下的IP为同一网段。

    在开发板键入:ifconfig eth0 192.168.1.15   

    之后挂载试试  mount -t nfs -o nolock 192.168.1.19:/home/ema/nfs_share /tmp/

    出现:mount: RPC: Unable to receive; errno = No route to host 解决:原因是没有接网线,接上试试。 情况二 :pc可以ping通虚拟机 但是虚拟机ping不通pc ,这种情况很可能是防火墙设置问题,ubuntu 下防火墙默认是关闭的。

    解决:关闭防火墙。

    情况三:对新安装的Ubuntu 挂载网络文件系统出现:

    当我挂载时 mount -t nfs -o nolock 192.168.1.138:/home/ema/nfs_share /tmp/  出现如下提示:

    mount: RPC: Unable to send; errno = Network is unreachable

    在开发板输入ifconfig eth0 192.168.1.15,配置开发板ip与宿主机在同一网段下:

    继续在开发板键入 mount -t nfs -o nolock 192.168.1.138:/home/ema/nfs_share /tmp/  出现如下提示: mount: RPC: Unable to receive; errno = Connection refused

    原因是没有安装nfs服务(因为是新安装的Ubuntu linux 系统)

    解决方法:

    安装nfs 服务sudo apt-get install nfs-kernel-server:(安装nfs-kernel-server时,apt会自动安装nfs-common和portmap) sudo vi /etc/exports /home/ema/nfs_share *(rw,sync,no_root_squash)

    :wq

    sudo /etc/init.d/nfs-kernel-server restart  <---重启nfs服务

    接着在开发板上mount -t nfs -o nolock 192.168.1.138:/home/ema/nfs_share /tmp/ 成功。

    *(rw,sync,no_root_squash) 解释:

       *     : 允许所有的网段访问 rw     : 读写权限 sync: 资料同步写入内存和硬盘 no_root_squash:nfs客户端共享目录使用者权限

    挂载命令解释:

    mount     :挂载命令 nfs       :使用的协议 nolock    :不阻塞 vers      : 使用的NFS版本号 IP        : NFS服务器的IP(NFS服务器运行在哪个系统上,就是哪个系统的IP,比如我的是ubuntu) /home/ema/nfs_share: 要挂载的目录(Ubuntu的目录) /tmp/     : 要挂载到的目录(开发板上的目录)

    注:对于较低版本的Ubuntu 如9.10的 还需要自己配置映射端口:

    sudo dpkg-reconfigure portmap sudo /etc/init.d/portmap restart                  <---重启portmap, sudo /etc/init.d/nfs-kernel-server restart 

    若是 执行完上面的命令后若都不行关闭secureCRT 重新操作一遍,再不行就只能另找原因了。

    转载请注明原文地址: https://ju.6miu.com/read-16262.html

    最新回复(0)