Raspberry Pi3 ~ 安装 nfs Server

 

l  安装必要服务:        

sudo      apt-get install  portmap 

sudo  apt-get install  nfs-kernel-server

sudo      apt-get install  portmap

                         

l  编辑文件         

sudo      vim /etc/exports  

添加:   

/home/pi/Myself      192.168.123.*(rw,sync,no_subtree_check)     

   * 表示最后一段任何IP都可以共享,如果你想限定个别IP,用IP替代

   注意要事先创建要共享的目录

参数

说明

ro

只读访问

rw

读写访问

sync

所有数据在请求时写入共享

async

nfs在写入数据前可以响应请求

secure

nfs通过1024以下的安全TCP/IP端口发送

insecure

nfs通过1024以上的端口发送

wdelay

如果多个用户要写入nfs目录,则归组写入(默认)

no_wdelay

如果多个用户要写入nfs目录,则立即写入,当使用async时,无需此设置

hide

在nfs共享目录中不共享其子目录

no_hide

共享nfs目录的子目录

subtree_check

如果共享/usr/bin之类的子目录时,强制nfs检查父目录的权限(默认)

no_subtree_check

不检查父目录权限

all_squash

共享文件的UID和GID映射匿名用户anonymous,适合公用目录

no_all_squash

保留共享文件的UID和GID(默认)

root_squash

root用户的所有请求映射成如anonymous用户一样的权限(默认)

no_root_squash

root用户具有根目录的完全管理访问权限

anonuid=xxx

指定nfs服务器/etc/passwd文件中匿名用户的UID

anongid=xxx

指定nfs服务器/etc/passwd文件中匿名用户的GID

l  启动NFS Server             

   
   

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

l  检查是否启动        

showmount      –e  localhost

发现启动不起来,卡主不动。解决方法:

l  在服务器上先停止rpcbind 和nfs在启动 注意顺序      

sudo      /etc/init.d/rpcbind  stop                     停止rpcbind   

sudo      /etc/init.d/nfs-kernel-server stop        停止nfs

sudo      /etc/init.d/rpcbind start                      启动rpcbind   

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

l  查看nfs状态:             

pi@raspberrypi:~ $ showmount  -e  localhost   

Export     list for localhost:

/home/pi/Myself     192.168.123.*   

出现目录和访问地址即可

l  客户端进行连接          

 mount  -t  nfs      -o  nolock  192.168.123.20:/home/pi/Myself  /mnt/nfs      

注意事先创建目录

原文地址:https://www.cnblogs.com/einstein-2014731/p/5542459.html