打开/etc/exports文件,在末尾加入:
/home/lj/nfs 172.28.24.0/255.255.255.0(rw,sync,no_root_squash)(以本人测试环境为例)
NOTE: 上面的主机IP不能使用*来通配,否则在客户机上会出现访问拒绝,但是如果我们要设置局域网访问呢?怎么办,使用子网掩码例如:10.1.60.0/255.255.254.0即可让10.1.60.*和10.1.61.*都可以访问,还可以使用10.1.60/23这种方式类确定子网。 注:nfs允许挂载的目录及权限,在文件/etc/exports中进行定义, 各字段含义如下: /home/lj/nf:要共享的目录 172.28.24.* :允许所有的网段访问 rw :读写权限 sync:资料同步写入内在和硬盘
3.3重启服务
#sudo /etc/init.d/portmap restart <---重启portmap,很重要 Rather than invoking init scripts through /etc/init.d, use the service(8) utility, e.g. service portmap restart Since the script you are attempting to invoke has been converted to an Upstart job, you may also use the restart(8) utility, e.g. restart portmap portmap start/running, process 474 #sudo /etc/init.d/nfs-kernel-server restart <---重启nfs服务 * Stopping NFS kernel daemon [ OK ] * Unexporting directories for NFS kernel daemon... [ OK ] * Exporting directories for NFS kernel daemon... exportfs: /etc/exports [1]: Neither 'subtree_check' or 'no_subtree_check' specified for export "*:/home/xgc". Assuming default behaviour ('no_subtree_check'). NOTE: this default has changed since nfs-utils version 1.0.x [ OK ] * Starting NFS kernel daemon [ OK ] #showmount -e <---显示共享出的目录 Export list for lj-desktop: /home/lj/nfs 172.28.24.0/255.255.255.0 虚拟机上查看nfs: #server nfs-kernel-server status nfsd running (# ./ethertp 0 5-2-1.log 0 NFS -h 172.28.24.236:/home/lj/nfs -f ../data_100M -l shareNFS0 1 1 -d) 问题: mount: RPC: Unable to send; errno = Network is unreachable 解决:保证主机和板子的ip在同一网段上; mount: RPC: Unable to receive; errno = No route to host 解决:连接板子和主机的网线可用,ping一下,看是否ping通;
联系客服